Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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'
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.
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.
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
When linking with shared library order is not important.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.