Hi,
I am a beginner with programming on linux.
I need to write a program using Libpcap
I downloaded and installed the package from tcpdump.org and can see the library libpcap.a at the location /usr/lib.
I have the following sample program named as test.c:
#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(1);
}
printf("Device: %s\n", dev);
return(0);
}
Following are the steps using which i compile it
gcc -c test.c
gcc test.o -lpcap
./test.o
-bash: ./test1.o: cannot execute binary file
I don't know why i am getting the above error
. I changed the permission of the object file to 777, it still does not work. Any other c program runs perfectly fine.
Any help in this will be appreciated.
Regards,
Sonia