WinPcap Visual C++
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: WinPcap Visual C++

  1. #1
    Join Date
    Dec 2010
    Posts
    3

    WinPcap Visual C++

    Hello,

    I have setup Visual C++ Express for use with WinPcap following the guide on the winpcap site ( http://www.winpcap.org/docs/docs_412...pcapsamps.html ). When I test a console app using winpcap, it will run fine, so I know it is setup properly. However, I have started to make a windows forms version of the console app. I put all the winpcap functions i made in a seperate header (functions.h) and I include this in the main form header. I haven't used the functions in the main header yet, only included them. I get a linker error:

    Code:
    1>app.obj : error LNK2031: unable to generate p/invoke for "extern "C" void __clrcall pcap_freealldevs(struct pcap_if *)" (?pcap_freealldevs@@$$J0YMXPAUpcap_if@@@Z); calling convention missing in metadata
    1>app.obj : error LNK2031: unable to generate p/invoke for "extern "C" int __clrcall pcap_findalldevs_ex(char *,struct pcap_rmtauth *,struct pcap_if * *,char *)" (?pcap_findalldevs_ex@@$$J0YMHPADPAUpcap_rmtauth@@PAPAUpcap_if@@0@Z); calling convention missing in metadata
    1>app.obj : error LNK2028: unresolved token (0A000040) "extern "C" void __clrcall pcap_freealldevs(struct pcap_if *)" (?pcap_freealldevs@@$$J0YMXPAUpcap_if@@@Z) referenced in function "void __clrcall getDevices(void)" (?getDevices@@$$FYMXXZ)
    1>app.obj : error LNK2028: unresolved token (0A000041) "extern "C" int __clrcall pcap_findalldevs_ex(char *,struct pcap_rmtauth *,struct pcap_if * *,char *)" (?pcap_findalldevs_ex@@$$J0YMHPADPAUpcap_rmtauth@@PAPAUpcap_if@@0@Z) referenced in function "void __clrcall getDevices(void)" (?getDevices@@$$FYMXXZ)
    1>app.obj : error LNK2019: unresolved external symbol "extern "C" void __clrcall pcap_freealldevs(struct pcap_if *)" (?pcap_freealldevs@@$$J0YMXPAUpcap_if@@@Z) referenced in function "void __clrcall getDevices(void)" (?getDevices@@$$FYMXXZ)
    1>app.obj : error LNK2019: unresolved external symbol "extern "C" int __clrcall pcap_findalldevs_ex(char *,struct pcap_rmtauth *,struct pcap_if * *,char *)" (?pcap_findalldevs_ex@@$$J0YMHPADPAUpcap_rmtauth@@PAPAUpcap_if@@0@Z) referenced in function "void __clrcall getDevices(void)" (?getDevices@@$$FYMXXZ)
    1>C:\Users\Jason\Desktop\win C++\project\app\Debug\app.exe : fatal error LNK1120: 4 unresolved externals
    please help!

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,605

    Re: WinPcap Visual C++

    This Forum is for VC++, not for "windows forms" problems. So either ask it in "Managed C++/CLI" Forum or. at least provide more info about your IDE version and you Application type and, probably, source code.
    Victor Nijegorodov

  3. #3
    Join Date
    Dec 2010
    Posts
    3

    Re: WinPcap Visual C++

    im not going to re-post it elsewhere. my IDE is Visual C++ 2010 Express. The program works fine as a "Win32 console application" but under windows forms application I get the linker errors above.
    thanks.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,605

    Re: WinPcap Visual C++

    Quote Originally Posted by JasonC++ View Post
    im not going to re-post it elsewhere.
    ... but under windows forms application I get the linker errors above.
    I am awfully sorry, but again:
    the "windows forms application" problems are discussed in another Forum.
    Victor Nijegorodov

  5. #5
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: WinPcap Visual C++

    Quote Originally Posted by JasonC++ View Post
    I have started to make a windows forms version of the console app. I put all the winpcap functions i made in a seperate header (functions.h) and I include this in the main form header. I haven't used the functions in the main header yet, only included them. I get a linker error:
    does it mean you've created a new project?

    if so, did you repeat these steps?
    --- Set the options of the linker to include the wpcap.lib library file specific for your target (x86 or x64). wpcap.lib for x86 can be found in the \lib folder of the WinPcap developer's pack, wpcap.lib for x64 can be found in the \lib\x64 folder.
    --- Set the options of the linker to include the winsock library file ws2_32.lib. This file is distributed with the C compiler and contains the socket functions for Windows. It is needed by some functions used by the samples in the tutorial.
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  6. #6
    Join Date
    Dec 2010
    Posts
    3

    Re: WinPcap Visual C++

    Thanks for the reply. I have repeated all steps to setup the compiler and linker for winpcap. And yes, I created a new project.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center