Re: [hatari-devel] Windows MSYS MinGW64 Build Failure |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: Chang Chong <codemonkey2x@xxxxxxxxx>
- Subject: Re: [hatari-devel] Windows MSYS MinGW64 Build Failure
- From: Thomas Huth <th.huth@xxxxxxxxx>
- Date: Fri, 2 Apr 2021 07:23:26 +0200
- Cc: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1617341008; bh=RD6fXV/NX+BM0trrRk9raWXba7v+a2s5ZmUYXgqzzZY=; h=Date:From:To:Cc:Subject:From; b=aC6cNLt41FwX/QwsGXcB5vTxL17k3I1EvV25dxqcDx4u9Vp+Pnz1N/+emspiUUdx2 vk3uIM8h6O9uLYB0o3SN6Bt61Tgzbq5EVEymHxGGqhIFBZkMM7lQIKRoeES8udS0Hx Dvtfj9xA/SvAfTWBGaJ7qRPmHVtulzttHi/+wHGXwOuFYXf/8tRjjxJmdcc9p7HVfn LfB0QSpuBDNOpyCsEqEAAogtX0D7tjmBXQ2h6ssn71MIuVEHfdcKm2hdHR169BZcSq uDJERnrjeHJz5+fYBGm6i3rMqE0ZWy4BMIkDIQZWMFAU1tpgNW+azSk+FGBY4syT+5 qPBhM651jFe6w==
Am Fri, 26 Mar 2021 10:17:49 -0500
schrieb Chang Chong <codemonkey2x@xxxxxxxxx>:
> I wanted to share my observations while trying to build a windows
> binary using msys2/mingw64 on a windows 10 machine. I installed SDL
> 2.0.14 via pacman.
>
> I used the cmake generator “MSYS Makefiles” (UNIX Makefiles would
> work as well). No issues getting the project configured with cmake
> and SDL2. However, most binaries fail to link with the error message:
>
> mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):
> in function `main':
> C:/_/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt0_c.c:18:
> undefined reference to `WinMain' collect2.exe: error: ld returned 1
> exit status
>
> After some troubleshooting, I found the issue is with a define in the
> compilation -Dmain=SDL_main. This is set by the pkg-config call in
> the main CMakeLists.txt:
>
> # Additional CFLAGS suggested by the SDL library:
> execute_process(COMMAND pkg-config --cflags-only-other sdl2
> OUTPUT_VARIABLE DETECTED_SDL_CFLAGS
> ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
> if(DETECTED_SDL_CFLAGS)
> add_definitions(${DETECTED_SDL_CFLAGS})
> # message(STATUS "Additional CFLAGS of SDL:
> ${DETECTED_SDL_CFLAGS}") endif(DETECTED_SDL_CFLAGS)
>
> output:
>
> $ pkg-config --cflags-only-other sdl2
> -Dmain=SDL_main
>
> The pkg-config executable is from /mingw64/bin/pkg-config.exe.
>
> The solution is to add ${SDL2_LIBRARY} to the target_link_libraries
> for all the failing executables.
I've once tried to compile Hatari with MSYS, too, and ran into similar
problems. The problem with "main" can be worked around with running
cmake like this, I think:
CFLAGS="-Umain" cmake -G "Unix Makefiles" .
However, I then also hit some other weird problems there (SDL header
files try to include the "memory.h" system header, but end up in
including the memory.h from Hatari), so I finally gave up. That
toolchain is simply not very suitable for compiling Hatari, I think.
Thomas