boost ws2_32.lib error

Hello.
I'm using boost.Asio and I've got some troubles: undefined references.
I Googled it up and found that the error is because of WinSock.
I know that using the (MinGW) -lw2_32 param will fix this, but how can I fix the issues and keep it cross-platform?

1
2
3
4
5
undefined reference to `__imp_WSACleanup'|
undefined reference to `__imp_WSASetLastError'|
undefined reference to `__imp_closesocket'|
undefined reference to `__imp_WSAGetLastError'|
undefined reference to `__imp_ioctlsocket'| 

Thanks.
Last edited on
What do you mean "keep it cross-platform"? In almost no case is an executable ever going to be cross platform, they are compiled in a format specific to the system architecture and operating system. Basically, you need to link to the library to get the functionality, and you simply link to a different library when making the executable on a different platform.
@NT3
You're wrong. At some cases, you really need compile it for one OS, but boost was made for cross-platform programming, like C++ (and you know it). Anyway, how I'll compile it for all OS?
Thanks
Use Python :)


closed account (Dy7SLyTq)
@iqchange: actually your wrong. an executable is very hard to make cross platform. do you know that linux doesnt even use exes as binaries? it recognizes it, but you compile things as elfs and bins. and boost is cross platform. if you write code that only contains the stl (well up to c++11) and boost then you are guaranteed by boost and the standard that it is cross platform code
Boost itself allows for crossplatform code development, but the things an OS gives you may vary.
Undefined references like that are impossible to resolve in a crossplatform way.
You certainly are never going to find an end to this topic, there's no standard to linking libraries from the source file (Only the VS allows #pragma comment, but it won't work for MinGW/GCC).

The nearest solution is to create multiple makefiles, one for every different operating system you want to support.
Topic archived. No new replies allowed.