problem linking against libpcap library.
i have compiled and intalled the library, 0.9.8, without any seeming problems, however when i try to link any object files which reference a function in libpcap, i get an undefined reference.
here is the sample code: <code> #include <pcap.> int main( void ) { char err[PCAP_ERRBUF_SIZE]; char dev[1024]; dev = pcap_lookupdev( err ); return 0; } </code> i can't make it any simpler than that -- the error exactly is: pcap.c:(.text+0xab): undefined reference to `pcap_lookupdev' if anyone has any ideas, i'll happily read them. thanks, go easy, -daniel |
Do you have the libpcap development libraries installed too? The development libs are different than the actual libpcap software.
|
hmm, i didn't think of that -- i'll try installing them and see if there is a difference.
stand by. *:). -daniel |
oikay ... maybe i'm stupid -- i've gone to tcpdump.org's website, but the links to download the dev or current libraries are both 404. any other location to try ? i've done the usual look around to no avail.
-daniel |
Quote:
|
i'll try those sites, thanks. i'm using Slackware 12.1, which has libpcap 0.9.8 bundled, which is what i'm currently linking against.
go easy, -daniel |
You didn't provide your Makefile.
How did you link your program ? Do you specify -lpcap and -L with path to your libpcap location ? |
yes. make file is:
gcc -lpcap pcap.c |
okay ... well, i figured out some of the problem i was having. i had been using the following compile command:
gcc -lpcap pcap.c instead i used: gcc pcap.c -lpcap which does link the files. i had thought the needed libraries needed to precede the reference to objects within those libraries. -daniel |
Quote:
When linking with static library (or just object files) undefined symboles looked at only in the yet unprocessed files. And processing is going from left to right. In case of circular dependencies one ca use linker's -( and -) switches but it make linking more slow. |
All times are GMT -5. The time now is 11:15 PM. |