Reputation: 1255
i want to read from a pcap file and used the winpcap libary ( http://www.winpcap.org/ ) for that. after downloading i installed it (and therefore i think their dlls got copied somewhere my system is searching for them). i want to STATIC link the libary to my project, because i dont want to add the winpcap dlls everytime on another computer(which wouldnt be a problem if the computer had installed winpcap too i guess).
in visual studio i added the include path for the headerfiles and the libary path. then i add the libarys "libwpcap.a" and "libpacket.a" to the additional dependencies. (there are also the files "wpcap.lib" and "packet.lib" in the directory, i think they are used for dynamic linking?). my code works fine but when i moved the executeable to my other computer, where i didnt installed winpcap before, it says missing wpcap.dll.. so its just dynamic linked, am i right?
but this case i wanted to prevent. so how can i tell the linker, that he has to link it static.. damn i am searching for it quite some time now. but i dont know what i am doing wrong :( thought .a files get static linked and .lib files are used to link dynamicly.
Upvotes: 0
Views: 1676
Reputation: 4407
Let's separate between three modes when linking on Windows using VS:
The .lib files of modes #1 and #3 are different. Which file is created depends on the settings the creator of the library built her project with: If its "Static Library", a full-implementation .lib file will be created. If it's "Dynamic Library", a stub .lib file and a .dll file will be created. If you use a stub .lib file, your executable will need the .dll file available at runtime.
To solve your problem: If the full-implementation .lib file is not available in the distribution you downloaded, you can download the full WinPCap source code (available from their website) and build it yourself as a static library.
Note, however, that the license might not allow you to do that. I have no idea - you should check this on your own.
Also see:
Upvotes: 7