2

I'm using WinPcap library in a visual C++ project. When I try to compile the project I get linker errors however I've correctly configured the project properties to include the appropriate files and libraries. Here are the errors I got :

Error LNK2019: unresolved external symbol _pcap_findalldevs_ex referenced in function _main consolewinpcap.obj
Error LNK2019: unresolved external symbol _pcap_geterr referenced in function _main consolewinpcap.obj
Error LNK2019: unresolved external symbol _pcap_next_ex referenced in function _main consolewinpcap.obj
Error LNK2019: unresolved external symbol _pcap_open referenced in function _main consolewinpcap.obj

UPDATE :

Here is a part of the ".vcproj" file

<Tool
   Name="VCCLCompilerTool"
   Optimization="0"
   AdditionalIncludeDirectories=".\WinPCap\Include"
   PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WPCAP"
   MinimalRebuild="true"
   BasicRuntimeChecks="3"
   RuntimeLibrary="3"
   UsePrecompiledHeader="2"
   WarningLevel="3"
   DebugInformationFormat="4"
/>
<Tool
   Name="VCManagedResourceCompilerTool"
/>
<Tool
   Name="VCResourceCompilerTool"
/>
<Tool
   Name="VCPreLinkEventTool"
/>
<Tool
   Name="VCLinkerTool"
   AdditionalDependencies="wpcap.lib Packet.lib"
   ShowProgress="0"
   LinkIncremental="2"
   AdditionalLibraryDirectories=".\WinPCap\lib"
   GenerateDebugInformation="true"
   SubSystem="2"
   TargetMachine="1"
/>

Any help would be appreciated.

Kira
  • 1,153
  • 4
  • 28
  • 63
  • WinPcap is a dynamic library, isn't it? Have you added the import library to your libraries to link? http://stackoverflow.com/questions/5218929/using-winpcap-in-vc-programs?rq=1 – harper Sep 24 '13 at 16:09
  • yes I did import them :/ – Kira Sep 25 '13 at 08:19
  • You could enable "Show Progress" in the Linker/General tab to see what's going on, e.g. if the library is really searched. – harper Sep 25 '13 at 10:44
  • @harper I couldn't find where it comes from :( **Please** check my update – Kira Sep 27 '13 at 09:45
  • @harper I've noticed that I have two "wpcap.lib" files in my project directory (one under "MyProject" and the other under "Myproject\WinPCap")and that's what made the Linker confused. I deleted one of them and now everything works fine. Thanks anyway :) – Kira Sep 27 '13 at 13:11

1 Answers1

1

When you are doubt about the linker process it's useful to enable the "Show Progress" option. You find it in the Linker/General tab.

If you don't use the GUI you can also change the .vcproject file. You find it here:

<Tool Name="VCLinkerTool"
    ShowProgress="1"
    ...
/>
harper
  • 13,345
  • 8
  • 56
  • 105