undefined reference to pcap_next_ex

Support issues for PHREL, the Per Host RatE Limiter.

undefined reference to pcap_next_ex

Postby sella » Sun Apr 16, 2006 4:38 am

If your build fails with "undefined referneces to pcap_next_ex" or other libpcap functions (see example errors below), then you may need to specifically install the dynamic or shared libraries for libpcap.

The normal build process for libpcap does not install a shared library (.so), but rather an archive (.a). Many Linux distributions come with older libpcap libraries and the PHREL build process will attempt to link them instead of the library archive.

To get around this issue, extract the libpcap tarball (eg: libpcap-0.9.4.tar.gz) in the same directory that the PHREL archive was extracted and build libpcap before running the PHREL configure script. This will allow PHREL to locate your newly created pcap library archive (libpcap.a) and link against it.

Optionally, you could replace your systems pcap library by via a package manager (RPM, etc) or manually by building libpcap as follows:

Code: Select all
> tar xvzf libpcap-0.9.4.tar.gz
> cd libpcap-0.9.4/
> ./configure --prefix=/usr
> su -c 'make install-shared'
> su -c 'rm /usr/lib/libpcap.so; ln -s libpcap.so.0.9.4 /usr/lib/libpcap.so'
> su -c '/sbin/ldconfig'


Example of "undefined refernece to pcap_next_ex" errors:

Code: Select all
gcc  -g -O2   -o phreld  capture.o data_hash.o phrel.o prefs.o thread.o util.o trap.o ../lib/libsnmptrap.a ../lib/libconfiguration.a -L/usr/local/lib -lnetsnmp -lcrypto -lm -pthread -lpcap
capture.o: In function `capture':
/home/sella/phrel/src/capture.c:125: undefined reference to `pcap_next_ex'
phrel.o: In function `main':
/home/sella/phrel/src/phrel.c:188: undefined reference to `pcap_lib_version'
prefs.o: In function `exclude_interfaces':
/home/sella/phrel/src/prefs.c:989: undefined reference to `pcap_findalldevs'
/home/sella/phrel/src/prefs.c:1026: undefined reference to `pcap_freealldevs'
collect2: ld returned 1 exit status
make[2]: *** [phreld] Error 1
Code: Select all
User avatar
sella
Site Admin
 
Posts: 81
Joined: Sat Jan 17, 2004 6:53 pm
Location: Denver, CO

Postby sella » Wed Apr 19, 2006 5:26 am

It was an older server with libpcap 0.6.2 on it, which isn't supported by PHREL.

-Jim
User avatar
sella
Site Admin
 
Posts: 81
Joined: Sat Jan 17, 2004 6:53 pm
Location: Denver, CO


Return to PHREL

Who is online

Users browsing this forum: No registered users and 2 guests

cron