psp1
psp1

Reputation: 537

How to resolve error "Undefined reference to `pcap_parse'"

I am trying to use the libpcap library in a C++ program.

I have downloaded libpcap-1.0.0.tgz, untared it, and then

./configer
make
make install

I have libpcap.a and headers with me, and I have written one sample program to test it. But it is giving me compiler errors as follows:

/usr/local/lib/libpcap.a(gencode.o): In function `.L151':
gencode.c:(.text+0x7f4): undefined reference to `pcap_parse'
collect2: ld returned 1 exit status

I am compiling this program using following command:

g++ -o test test.cpp -lpcap

Am i doing anything wrong in building libpcap and headers?

Upvotes: 1

Views: 5307

Answers (4)

Praveen Patel
Praveen Patel

Reputation: 519

Include grammar.c which gets generated after you run ./configure and make.

Upvotes: 0

alexmurray
alexmurray

Reputation: 925

Try installing libstdc++-4.8-dev - this worked for me when I had a similar issue.

Upvotes: 1

Rafik Harzi
Rafik Harzi

Reputation: 33

You have to install Libpcap-devel using this command ( sudo apt-get install libpcap-dev ) if it doesn't work install flex too (sudo apt-get install bison)

good luck

Upvotes: 0

ThiefMaster
ThiefMaster

Reputation: 318468

I'm pretty sure you need to pass -lpcap before test.cpp

Upvotes: 1

Related Questions