ws2_32.lib vs. libws2_32.a, what's the difference and how to link libws2_32 to NB project?

主宰稳场 提交于 2019-12-04 19:28:16
  1. It seems to me that you've added the -lws2_32 switch to the C/C++ compiler options. When netbeans invokes the compiler, it passes on the -c switch and it'll ignore the linker options, such as -l. In the linker options section, Netbeans has an apropriate place to add external libraries. Or you can add the -l as an extra option to the linker. That might solve the problem.

  2. *.lib files are used by the Microsoft toolchain (cl.exe) and lib*.a are used by GNU toolchain (that's the piece of adivse you've found). If you're going to use Cygwin, you'll need the lib*.a files. In this context, having Microsoft SDK won't help you at all. Also, if you need a file that only exists in .lib format, you can convert to.a` with a tool called reimp.

Hope this helps.

G O'Rilla

I had this problem Eclipse/CDT/Windows. This is my build command

g++ -O0 -g3 -Wall -c -fmessage-length=0 -o source\Sever_B.o ..\source\Sever_B.cpp
g++ -LC:\MinGW\lib -o Sever_B.exe source\Sever_B.o -lws2_32

So on the Eclipse project properties, C/C++ General, Paths & Symbols

  • Add C:\MinGW\lib to library paths tab
  • Add ws2_32 to libraries tab

This links libws2_32.a to my project and it now builds OK.

I tried using the Windows ws2_32.dll and ws2_32.lib and got nothing but pain.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!