Re: [hatari-devel] Windows cross compile build inconsistencies with SDL2

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Am Mon, 29 Mar 2021 14:56:06 -0500
schrieb Chang Chong <codemonkey2x@xxxxxxxxx>:

> This is a follow-up to my post yesterday regarding windows builds on
> a windows machine with msys2/mingw64. As part of my troubleshooting,
> I started looking into cross compiling the Hatari windows binary on
> my debian 10.8 (buster) machine as this appears to be the common
> route for windows builds.
> 
> The inconsistency issue comes from these lines in the hatari
> CMakeLists.txt file:
> 
> # 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)
> 
> There are two scenarios to consider for cross compiled windows builds
> and SDL2. 
> 
> Scenario 1: Linux install of SDL2 via its package manager and mingw
> SDL2 install
> 
> on my debian machine, i installed SDL2 v2.0.9 using apt. I also
> installed the mingw SDL2 v2.0.14 by downloading the tgz file from
> libsdl and running make cross with the correct prefix install
> directory.
> 
> In this scenario, when you run cmake with the cross compile
> toolchain, you will actually be getting the cflags from the linux
> SDL2 install. that’s because, pkg-config doesn’t know about the mingw
> SDL2 package config file. If you run pkg-config from the command line
> (like cmake would), you will get this:
> 
> $ pkg-config --cflags-only-other sdl2
>    -D_REENTRANT
> 
> and this is the cflag you will cross compile with.
> 
> The correct output for mingw SDL2 v 2.0.14 should be:
> -Dmain=SDL_main

Oh, you're right! When cross-compiling, we should not use the
pkg-config of the host, but e.g. i686-w64-mingw32-pkg-config instead.
I've now pushed a patch that should use the right pkg-config with our
MinGW toolchain files. (Alternatively, you can also set the PKG_CONFIG
environment variable to point to the right binary)

I've also moved the extra CFLAGS to the src folder since that's the
only place where we link with the SDL library, so hopefully that should
fix the problem with main vs. SDL_main vs. WinMain, too.

 Thomas



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/