error: undefined reference to `__imp_WSAStartup'
-
@SamiV123 said in error: undefined reference to `__imp_WSAStartup':
the less you need to mess with CMake or (build files in general) the better.
Using some non-standard stuff instead standarized scripting is for sure much better.
If you would have read the post from above you would see that the OP is using MinGW which does not support this crap. -
@Christian-Ehrlicher said in error: undefined reference to `__imp_WSAStartup':
@SamiV123 said in error: undefined reference to `__imp_WSAStartup':
the less you need to mess with CMake or (build files in general) the better.
Using some non-standard stuff instead standarized scripting is for sure much better.
If you would have read the post from above you would see that the OP is using MinGW which does not support this crap.Nothing standard about "scripting" (which I believe you use to refer to CMake) . But yeah, some of us prefer to have things the easy way and some don't...
-
@SamiV123 said in error: undefined reference to `__imp_WSAStartup':
But yeah, some of us prefer to have things the easy way and some don't...
Your idea will simply not work for the OP...
-
@wwwsharq for this error there are so many resone and i personally faced many problems
You should try to rearrange your header files.Try the following way which is i used.
#define WIN32_LEAN_AND_MEAN #include <windows.h> #include <WinSock2.h> #include <WS2tcpip.h> #include <NetCon.h> #pragma comment (lib, "Ws2_32.lib") #pragma comment (lib, "Mswsock.lib") #pragma comment (lib, "AdvApi32.lib")
-
@Ketan__Patel__0011
Have you verified these#pragma comment (lib, ...
statements work from MinGW? They are not just an MSVC thing?Maybe your re-ordering of the headers will help, I don't know, but I don't see how this will solve MinGW not knowing to link with Ws2_32, which seems to be the error message.
Same sort of thing as @SamiV123 above. Don't forget the OP actually already has
#pragma comment(lib, "Ws2_32.lib")
in his original code question, and it's still not linking....
-
@JonB said in error: undefined reference to `__imp_WSAStartup':
They are not just an MSVC thing
The pragma is proprietary MSVC crap
-
@Christian-Ehrlicher I know. I was inviting @Ketan__Patel__0011 to consider his answer for the OP with MinGW in this light.
-
@JonB Well i am using this conecpt in MSVC based Application and i also tried with MinGW Application and it's working very well.
But For MinGW you have to do one more thing.
just add below code in your .pro fileLIBS += -lWs2_32 LIBS += -lMswsock LIBS += -lAdvApi32
-
@Ketan__Patel__0011
So for MinGW the#pragma comment (lib, "Ws2_32.lib")
has no effect, that is why you have to add the-lWs2_32
etc. explicitly to get the link to happen. Which is just what we said --- the#pragma
is for MSVC only.If you read what the OP is asking you will see that are using cmake, not qmake, no
.pro
file. So yourLIBS
lines do not help them. And they are asking precisely what equivalent they have to do for cmake (which I do not know). -
@Ketan__Patel__0011 What are you discussing here? The op already used this three days ago...
target_link_libraries(eccoci PRIVATE ws2_32)