nats.c icon indicating copy to clipboard operation
nats.c copied to clipboard

Support linking with MinGW toolchains on Linux

Open XJ-0461 opened this issue 1 year ago • 1 comments

In the top level CMakeLists file, the line: set(NATS_EXTRA_LIB "Ws2_32")

Causes linker errors when cross-compiling cnats to Windows under Linux using the mingw toolchains. Because of the uppercase 'W'.

/usr/lib/gcc/x86_64-w64-mingw32/14.1.1/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lWs2_32: No such file or directory

On linux libraries are case-sensitive, and can be found (depending on your toolchain choice) at:

  • /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libws2_32.a
  • /usr/i686-w64-mingw32/sys-root/mingw/lib/libws2_32.a
  • /usr/x86_64-w64-mingw32ucrt/sys-root/mingw/lib/libws2_32.a

On Windows case-sensitivity is not a problem, so changing to lowercase "ws2_32" is fine.

XJ-0461 avatar Jun 12 '24 23:06 XJ-0461