Here are the steps:
- Download libpcap-1.3.0.tar.gz from http://www.tcpdump.org/ and decompress it;
- Download flex-2.5.37.tar.gz from http://flex.sourceforge.net/ and decompress it;
- Download bison-2.7.tar.gz from ftp://ftp.gnu.org/gnu/bison/ and decompress it;
- Download m4-1.4.16.tar.gz from ftp://ftp.gnu.org/gnu/m4/ and decompress it;
- Then, enter into directories m4-1.4.16, bison-2.7, flex-2.5.37 and libpcap-1.3.0 in order, and execute the following commands:
- $ sudo ./configure
- $ sudo make
- $ sudo make install
- ** Basically, just find the latest version from these websites to download.
#include <stdio.h>
#include <pcap.h>
int main(int argc, char *argv[])
{
char *dev, errbuf[PCAP_ERRBUF_SIZE];
dev = pcap_lookupdev(errbuf);
if (dev == NULL) {
fprintf(stderr, "Couldn't find default device: %s\n", errbuf);
return(2);
}
printf("Device: %s\n", dev);
return(0);
}
Commands to compile and execute this program:
- $ gcc test.c -lpcap
- $ sudo ./a.out
- ** use sudo to execute the program, because of permission required
Device: eth0
One problem you may come across during running the program:
"error while loading shared libraries: libpcap.so.1: cannot open shared object file: No such file or directory"
This is because we have installed using .tar.gz, then library is installed in /usr/local/lib directory.
Solution:
Open /etc/ld.so.conf as root, and add the following two lines to it:
/usr/local/lib
/usr/lib
Then execute command:
$ sudo ldconfig
Now compile and run test.c again, and you may get the result.
-------------------------------------------------------------------------------------------------------------------------------------
Download libpcap-1.0.0.tar.gz (512.0KB) from www.tcpdump.org, and decompress it (tar zxvf libpcap-1.0.0.tar.gz) to your self-defined directory;Download flex-2.5.35.tar.gz (1.40MB) from flex.sourceforge.net, and decompress it (tar zxvf flex-2.5.35.tar.gz) to your self-defined directory;Download bison-2.4.1.tar.gz (1.9MB) from ftp.gnu.org/gnu/bison/, and decompress it (tar zxvf bison-2.4.1.tar.gz) to your self-defined directory;Download m4-1.4.13.tar.gz (1.2MB) from ftp.gnu.org/gnu/m4/, and decompress it (tar zxvf m4-1.4.13.tar.gz) to your self-defined directory;Then, enter into the directories m4-1.4.13, bison-2.4.1, flex-2.5.35, libpcap-1.0.0 in the order, and execute the following commands:(sudo) ./configure(sudo) make(sudo) make install
http://ftp.gnu.org/gnu/m4/
ReplyDeletehttp://ftp.gnu.org/gnu/bison use this url.
I can't install this
Sorry, I haven't used it for a long time. But I guess it may be the problem of version.
Deleterenjith..
Deletetry these link for bison and m4..
http://ftp.gnu.org/gnu/m4/
http://ftp.gnu.org/gnu/bison/
i hope it will solve ur problem..
hello sir
ReplyDeletethank for this
i need to know what should i do after download all fill zip
put in same folder then upload because when i do ask me copy file overrite same file found so what should i do
atm-live.com
I'm afraid I cannot really understand your problem. Do you mean overwriting happened during decompression?
DeleteSolved my purpose. Thanks.
ReplyDeletethanks
ReplyDeleteFor UbUntU m4,flex,bison can directly be installed
ReplyDeleteapt-get install m4 flex bison
Yeah thanks. Would have been nice to have some explanations on what are each of this packet for? M4 ? Flex ? Bison ?
ReplyDeleteIn ubuntu 12, add these to libc.conf (or any of the conf) in /etc/ld.so.conf.d
ReplyDeletethanks a lot..before come to this page i wasted my 6 hrs but finally succeeded to install libpcap...
ReplyDeletei installed libpcap but now when i execute the above given program am getting the error ./a.out:error while loading shared libraries:libpcap.so.1:cannot open shared object file:No such directory or file. can any one provide a soln asap
ReplyDeletethank u . problem solved
ReplyDeletehi i can't find libpcap.so in mac please tell me what to do???
ReplyDeleteFirstly, Thanks a lot mate. It really helped. Amazing!
ReplyDeleteIt will be nice if you can add the following along with the above process.
Adding lines to ld.so.conf with the following command!
sudo sh -c "echo '/usr/local/lib' >> /etc/ld.so.conf"
Cheers!!
Thanks a mil for this
ReplyDeletewow this really saved me hours of time Thanks a lott !!!
ReplyDeleteYour guidance really helped me a lot :) Keep it up!
ReplyDelete