tl;dr I can compile, but it's gross and I'm guessing there's a better way.
I have a multithreaded app that I am compiling to each OS. For Windows, I have this extra step that I'm sure has a better answer. When I compile to windows, nim throws an error passed from the C compiler that basically 'lpthread' doesn't work. I already specify the pthread.a from MinGW in the nim compile command with passC and passL, so what I do is simply copy the entire screenfull of the failed C linker command, remove the last little '-lpthread' then paste back into the terminal and get a successful build.
Is there a way I can tell nim that I am statically linking pthread? I tried --dynlibOverride:pthread with no difference.
Possibly Useless Details
C compiler: zig
Nim version: 2.0.2
Host OS: linux
Full nim command:
nim c --os:windows -d:mingw --amd64.windows.gcc.exe:gcc-win --amd64.windows.gcc.linkerexe:gcc-win --mm:arc -o:myapp.exe --passC:-Imingw64/include --passL:mingw64/lib/libpthread.a -d:release myapp.nim
functionally the same and is shorter
nim c --os:windows --cc:gcc --gcc.exe:gcc-win --gcc.linkerexe:gcc-win --mm:arc -o:myapp.exe --passC:-Imingw64/include --passL:mingw64/lib/libpthread.a -d:release myapp.nim
"-lpthread" flag is added by the default nim.cfg:
# Configuration for the GNU C/C++ compiler:
@if windows:
...
@if gcc:
gcc.options.linker %= "-Wl,-Bstatic -lpthread"
@end
...
@end
To override it - create a local nim.cfg in project directory with this content:
@if windows:
@if gcc:
gcc.options.linker = "-Wl,-Bstatic"
@end
@end