Mohammad Dadashzadeh(deleted)
|
|
Mohammad Dadashzadeh(deleted)
07/24/2009 11:09 AM
post34520
|
Dear all,
I am a beginner in using QNX. I would like to use pcap.h to capture MAC packets. I am using bellow code to read all the
network devices. Code complies without any error. However, when I want to build the project it gives me below error. I
would be very thankful if someone helps me.
Description Resource Path Location Type
make[2]: *** [C:/ide-4.6-workspace/packetcapture2/x86/o-g/packetcapture2_g] Error 1 packetcapture2 line 0 C/C++ Problem
make[2]: *** [C:/ide-4.6-workspace/packetcapture2/x86/o/packetcapture2] Error 1 packetcapture2 line 0 C/C++ Problem
packetcapture2.c: undefined reference to `pcap_findalldevs' packetcapture2 line 0 C/C++ Problem
packetcapture2.c: undefined reference to `pcap_freealldevs' packetcapture2 line 0 C/C++ Problem
undefined reference to `pcap_findalldevs' packetcapture2.c packetcapture2 line 15 C/C++ Problem
undefined reference to `pcap_freealldevs' packetcapture2.c packetcapture2 line 38 C/C++ Problem
My code
#include <stdlib.h>
#include <stdio.h>
#include "pcap.h"
int main(int argc, char *argv[]) {
pcap_if_t *alldevs;
pcap_if_t *d;
int i=0;
char errbuf[PCAP_ERRBUF_SIZE];
printf("Welcome to the QNX Momentics IDE\n");
/* Retrieve the device list from the local machine */
if (pcap_findalldevs(&alldevs, errbuf) == -1)
{
fprintf(stderr,"Error in pcap_findalldevs_ex: %s\n", errbuf);
exit(1);
}
/* Print the list */
for(d= alldevs; d != NULL; d= d->next)
{
printf("%d. %s", ++i, d->name);
if (d->description)
printf(" (%s)\n", d->description);
else
printf(" (No description available)\n");
}
if (i == 0)
{
printf("\nNo interfaces found! Make sure WinPcap is installed.\n");
return;
}
/* We don't need any more the device list. Free it */
pcap_freealldevs(alldevs);
return EXIT_SUCCESS;
}
|
|
|