Results 1 to 4 of 4
I am trying to compile a simple c++ pcap program.
I installed pcap using sources->./configure->make->make install
Here is the code and the linking (not compiling) error:
Code:
filosottile.at.filosottile-desktop:~/Filo-CM$ cat monitor.cpp
...
- 06-23-2009 #1Just Joined!
- Join Date
- Jun 2009
- Posts
- 2
g++ not finds the lib
I am trying to compile a simple c++ pcap program.
I installed pcap using sources->./configure->make->make install
Here is the code and the linking (not compiling) error:
Can someone help me, please?Code:filosottile.at.filosottile-desktop:~/Filo-CM$ cat monitor.cpp #include <stdio.h> #include <pcap.h> int main(int argc, char *argv[]) { char *dev, errbuf[PCAP_ERRBUF_SIZE]; dev = pcap_lookupdev(errbuf); if (dev == NULL) { fprintf(stderr, "Couldn't find default device: %s\n", errbuf); return(2); } printf("Device: %s\n", dev); return(0); } filosottile.at.filosottile-desktop:~/Filo-CM$ ls /usr/local/lib libpcap.a python2.6 site_ruby filosottile.at.filosottile-desktop:~/Filo-CM$ g++ -L/usr/local/lib monitor.cpp -llibpcap /usr/bin/ld: cannot find -llibpcap collect2: ld returned 1 exit statusLast edited by FiloSottile; 06-23-2009 at 02:58 PM. Reason: added please ;)
- 06-23-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Because you installed it in /usr/local you need to add /usr/local/lib to your LD_LIBRARY_PATH environment variable. From your command line where you are running the executable:
You can add that to your ~/.bash_profile so it will be set for all your applications the next time you login.Code:export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/libSometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 06-23-2009 #3Just Joined!
- Join Date
- Jun 2009
- Posts
- 2
But why "-L/usr/local/lib" didn't work?
- 06-23-2009 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote
