yglukhov / nimx

GUI library
MIT License
1.1k stars 75 forks source link

Compilation for Windows on Linux fails with "undefined reference to `WinMain'" #246

Closed vanous closed 7 years ago

vanous commented 7 years ago

Hello,

new to nim and nimx. setting up my environment (debian amd64). Compilation of your hello world on linux for linux works OK, but when trying to cross compile for WIN target:

nim --os:windows --cpu:amd64 --gcc.exe:x86_64-w64-mingw32-gcc --gcc.linkerexe:x86_64-w64-mingw32-gcc --app:gui -r --noMain --threads:on c main.nim

it fails (probably during linking) with this message:

/usr/lib/gcc/x86_64-w64-mingw32/6.3-win32/../../../../x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): In function main': ./mingw-w64-crt/crt/crt0_c.c:18: undefined reference toWinMain' collect2: error: ld returned 1 exit status

Full log here: https://pastebin.com/UwfB8D4J

Or do i need to cross-compile libsdl2 first?

thank you

Tormund commented 7 years ago

You can try compile with -d:nimxAvoidSDL to use experimental winapi instead of sdl.

vanous commented 7 years ago

thank you, bu no luck, same error:

nim --os:windows --cpu:amd64 --gcc.exe:x86_64-w64-mingw32-gcc --gcc.linkerexe:x86_64-w64-mingw32-gcc --app:gui -r --noMain --threads:on -d:nimxAvoidSDL c main.nim

/usr/lib/gcc/x86_64-w64-mingw32/6.3-win32/../../../../x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): In function main': ./mingw-w64-crt/crt/crt0_c.c:18: undefined reference toWinMain'

yglukhov commented 7 years ago

Don't use --noMain. For windows we need WinMain.

nim --os:windows --cpu:amd64 --gcc.exe:x86_64-w64-mingw32-gcc --gcc.linkerexe:x86_64-w64-mingw32-gcc --app:gui -r --threads:on c main.nim
vanous commented 7 years ago

thank you, this worked!