Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - using pcap.h: Page 1 of 11 (11 Items)
   
using pcap.h  
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;
}