tcpdump mailing list archives

Re: Re: compile failed when using pcap, "undefined reference to `pcap_set_datalink"


From: Guy Harris <guy () alum mit edu>
Date: Fri, 28 Nov 2003 19:37:25 -0800

On Fri, Nov 28, 2003 at 01:21:52PM +0000, Arthur Chen wrote:
    now I have found part of the error.
1) my system is redhat 9.0, and I installed pcap with these steps:
                root# ./configure
                root# ./make
                root# ./make install

As I suspected.  You do, in fact, have an OS that comes with libpcap,
and you did, in fact, download (presumably from tcpdump.org), built, and
installed.

   with these steps, in the Makefile's item 'install:', it showed out these 
things to do
           (a) copy libpcap.a to /usr/local/lib,
           (b)copy pcap.h, pcap-named.h pcap-bpf.h to /usr/local/include
2) It seems the 'configure' shell is wrong,
           (a) copy libpcap.a to /usr/local/lib,----this should be copy to 
/usr/lib
           (b)copy pcap.h, pcap-named.h pcap-bpf.h to 
/usr/local/include-----this is wrong, should be copy to /usr/include

No, neither of those are wrong.  It's *supposed* to default to
installing under "/usr/local", to keep stuff built and installed locally
distinct from stuff that's part of the OS.

If you want to install in the standard system directories, the flag
"--prefix=/usr", passed to the configure script, might work.

3)But after I copied them to the correct place, I still can not compile, the 
error is still be:
"undefined reference to 'pcap_set_datalink'"
I have noticed that under the directory /usr/lib, there are several shared 
library files called libpcap.so, 
libpcap.so.0,libpcap.so.0.6,libpcap.so.0.6.2 , they might be the key 
problem---because when I make and instal the new PCAP library, I didn't see 
that there were any of these files be createdl:

They *weren't* created from the libpcap installation.  They're the
libraries that come with the OS.

The only way to fix that problem would be to remove the ".so" libraries
(well, library - only one of them is a library file, the others are
links to that library file) - *HOWEVER*, doing so would prevent any
programs built with those shared libraries from working!

Had you left the tcpdump.org versions of the header files and libraries
in directories under "/usr/local", you could have compiled your program
with the flags "-I/usr/local/include" and "-L/usr/local/lib", and your
program would have been compiled and linked with the tcpdump.org version of
libpcap, rather than with the version that came with RH 9.0.

Unfortunately, you didn't.  This means you've overwritten the versions
that come with the OS - and you don't want to remove them, as they might
cause some programs not to work (such as the version of tcpdump that
comes with RH 9.0, and possibly versions of other programs as well).

I'd suggest re-installing the RPMs for libpcap that came with RH 9.0,
re-installing the tcpdump.org libpcap under "/usr/local" (the default),
and compiling your program with "-I/usr/local/include" and
"-L/usr/local/lib".
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:tcpdump-workers-request () tcpdump org?body=unsubscribe


Current thread: