Thread: WinPcap with Dev C++

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    6

    WinPcap with Dev C++

    Hey so I have been trying to get the WinPcap libraries to work with Dev C++ for the last couple days and have had no luck. It seems everyone else is having the same problems as I checked the internet and all I seem to find is reports of this problems but no solutions. So I will try to make this as understandable as possible. I installed the appropriate drivers for the libraries. I have saved the contents of the WinPcap libraries into Dev C++'s lib folder. I saved the required includes (.h files) into the the include folder in the Dev C++ directory. I then made some changes to one of the C examples provided, and created a new C++ project. I linked to wpcap.lib and libws2_32.a and then compiled it. Here is the code and error I got.

    Code:
    #include <pcap.h>
    
    int main()
    {
        pcap_if_t *alldevs;
        pcap_if_t *d;
        int i=0;
        char errbuf[PCAP_ERRBUF_SIZE];
        
        /* Retrieve the device list from the local machine */
        if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1)
        {
            cout << "Error in pcap_findalldevs_ex: %s\n";
            return 0;
        }
        
        /* 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 0;
        }
    
        /* We don't need any more the device list. Free it */
        pcap_freealldevs(alldevs);
    
        return 0;
    }
    Code:
    Compiler: Default compiler
    Building Makefile: "C:\Users\Scott\Documents\c++ workspace\scoket workspace\syn test v1\Makefile.win"
    Executing  make...
    make.exe -f "C:\Users\Scott\Documents\c++ workspace\scoket workspace\syn test v1\Makefile.win" all
    g++.exe -c main.cpp -o main.o -I"C:/Program_Files/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Program_Files/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Program_Files/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Program_Files/Dev-Cpp/include/c++/3.4.2"  -I"C:/Program_Files/Dev-Cpp/include"   
    
    main.cpp: In function `int main()':
    main.cpp:11: error: `PCAP_SRC_IF_STRING' undeclared (first use this function)
    main.cpp:11: error: (Each undeclared identifier is reported only once for each function it appears in.)
    main.cpp:11: error: `pcap_findalldevs_ex' undeclared (first use this function)
    main.cpp:13: error: `cout' undeclared (first use this function)
    
    make.exe: *** [main.o] Error 1
    
    Execution terminated
    For some reason it isn't registering that certain functions are in the library. I also linked to libwpcap.a just to be sure but nothing changed. Also I know there are other errors in the code I.E. me not defining any standard libraries but this is just to illustrate a point and get the problem fixed im actually just using these select functions in a much bigger project and just posted this as a quick demo. Any thoughts?
    Last edited by ScottyK; 11-09-2010 at 11:47 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Whats better, C-Free or Dev C++??
    By i_can_do_this in forum Tech Board
    Replies: 10
    Last Post: 07-07-2006, 04:34 AM
  2. New to Dev C++/<windows.h>...
    By Cilius in forum C++ Programming
    Replies: 3
    Last Post: 02-23-2005, 01:05 AM
  3. Glut and Dev C++, Programs not Quitting?
    By Zeusbwr in forum Game Programming
    Replies: 13
    Last Post: 11-29-2004, 08:43 PM
  4. openGL programming - From MSVC++ to Dev C++
    By WDT in forum Game Programming
    Replies: 1
    Last Post: 03-08-2004, 05:19 PM
  5. DEV C++ Limitations?
    By Kirdra in forum Game Programming
    Replies: 3
    Last Post: 09-09-2002, 09:40 PM