undefined reference to `__imp_WSACleanup'
add
-lwsock32
to your command-line instead of #pragma
when compiling with MinGW
g++ src/main.cpp -o release/myApp.exe -lwsock32
I met the same problem with you. I solved it by adding a command -lwsock32
.
you can add the command according follow steps:
- tools
- compiler options
- choose
general
- click
add the following commands when calling the compilers
then you can add the above command -lwsock32
.
In DevC++, navigate to Project >> Project Options (or via usually ctrl+h); then in the "Parameters" tab there is a button "Add Library or Object" and then add libws2_32.a
.
The pragma you use only works for the Visual C++ Compiler and will be ignored by the gcc
#pragma comment(lib, "ws2_32")
you have to add the ws2_32.lib it manually in the makefile. like:
-L"ws2_32"
(I guess it was without the ".lib" at the end)
at the end of the g++ line. You have of course add the full path which I have not by hand at the moment.