I am on mac and trying to compile dynamic libraries for Windows (for a game im making in Godot). Right now my solution to compiling involves a USB stick and rebooting...
I try to compile for windows like so: nim c -d:mingw my_file.nim
I get: (i installed mingw with brew) 'vccexe.exe /c --platform:amd64 /nologo -DWIN32_LEAN_AND_MEAN /Zi /FS /Od /I/Users/stefanlund/.choosenim/toolchains/nim-1.4.4/lib /I/Users/projects/turing_complete/nim /nologo /Fo'/Users/stefanlund/.nimcachewindowsamd64/stdlib_sharedlist.nim.c.obj' '/Users/stefanlund/.nimcachewindowsamd64/stdlib_sharedlist.nim.c'' failed with exit code: 127
I should mention I have a bunch of arguments in a .cfg file, but I would guess they aren't related:
Any help welcome.
from the nim compiler's nim.cfg:
@if unix and mingw:
# Cross compile for Windows from Linux/OSX using MinGW
i386.windows.gcc.exe = "i686-w64-mingw32-gcc"
i386.windows.gcc.linkerexe = "i686-w64-mingw32-gcc"
i386.windows.gcc.cpp.exe = "i686-w64-mingw32-g++"
i386.windows.gcc.cpp.linkerexe = "i686-w64-mingw32-g++"
amd64.windows.gcc.exe = "x86_64-w64-mingw32-gcc"
amd64.windows.gcc.linkerexe = "x86_64-w64-mingw32-gcc"
amd64.windows.gcc.cpp.exe = "x86_64-w64-mingw32-g++"
amd64.windows.gcc.cpp.linkerexe = "x86_64-w64-mingw32-g++"
@if macosx:
i386.windows.gcc.path = "/usr/local/bin"
amd64.windows.gcc.path = "/usr/local/bin"
@else:
i386.windows.gcc.path = "/usr/bin"
amd64.windows.gcc.path = "/usr/bin"
@end
os = windows
gcc.options.linker = ""
gcc.cpp.options.linker = ""
@end
Also you can give the flags "--hint:cc --hint:link" to see log details about the used toolchainHere's my working setup from my min project:
# https://blog.filippo.io/easy-windows-and-linux-cross-compilers-for-macos/
switch("amd64.windows.gcc.path", "/usr/local/bin")
switch("amd64.windows.gcc.exe", "x86_64-w64-mingw32-gcc")
switch("amd64.windows.gcc.linkerexe", "x86_64-w64-mingw32-gcc")
switch("amd64.linux.gcc.path", "/usr/local/bin")
switch("amd64.linux.gcc.exe", "x86_64-linux-musl-gcc")
switch("amd64.linux.gcc.linkerexe", "x86_64-linux-musl-gcc")
The link in the comment is the key really.
However, I recently stopped cross compiling locally and I am now using a GitHub action... less hassle overall:
https://github.com/h3rald/min/blob/master/.github/workflows/add-artifacts-to-current-release.yml