0

I am trying to compile ethping
Here is the command that gets issued via make:

gcc -Wall -Werror -ggdb -g -O2 -lpcap  -o ethping ethping.o ieee8021ag.o dot1ag_eth.o

I now get this error message:

/dot1ag-utils-master/src/ethping.c:65: undefined reference to `pcap_breakloop'

Indicating that it cannot find the pcap.h.

So I type:

root:src# whereis pcap.h
pcap: /usr/include/pcap.h /usr/include/pcap /usr/share/man/man3/pcap.3pcap.gz
root:src# 



root:src# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/include

And the /usr/include is definitely in my path.

The only thing that might be an issue is that /usr/include/pcap.h is a stub file that does and include of pcap/pcap.h.

/*
 * For backwards compatibility.
 *
 * Note to OS vendors: do NOT get rid of this file!  Many applications
 * expect to be able to include <pcap.h>, and at least some of them
 * go through contortions in their configure scripts to try to detect
 * OSes that have "helpfully" moved pcap.h to <pcap/pcap.h> without
 * leaving behind a <pcap.h> file.
 */
#include <pcap/pcap.h>

So in /usr/include/pcap/pcap.h is the actual file contents with those definitions present.

RobM
  • 111
  • 1
  • 4
  • **Header files are not libraries**. Undefined references are *link-time errors*, they mean you are either missing a library directive on the gcc command line, or (more likely in this case) are listing libraries in the wrong order (i.e. `-lpcap` must be to the right of object files that depend on its symbols). – steeldriver Feb 05 '15 at 15:13
  • I.e., no, the error does *not* indicate that it could not find pcap.h; if it couldn't find pcap.h, it would have said so. It indicates that, for some reason, it couldn't find `pcap_breakloop()` in libpcap; what does the command `tcpdump -h` print? –  Feb 05 '15 at 18:46
  • root:dot1ag-utils-master# tcpdump -h tcpdump version 4.5.1 libpcap version 1.5.3 – RobM Feb 05 '15 at 22:08
  • aaaaggghhh steeldriver you had it right I moved -lpcap to the end and it worked!gcc -Wall -Werror -ggdb -g -O2 -I /usr/include/pcap -o ethping ethping.o ieee8021ag.o dot1ag_eth.o -lpcap – RobM Feb 05 '15 at 22:11

1 Answers1

1

You have to install not only the header files, but the libraries also. These are the packages ending in -dev, so in this case:

sudo apt-get install libpcap-dev

By the way, this is a metapackage, which will install libpcap0.8-dev package.

meskobalazs
  • 2,883
  • 17
  • 26
  • Sorry I forgot to mention the libpcap-dev is installed as well allready when I am getting the error – RobM Feb 05 '15 at 22:07