Fix compilation with MinGW32
There is still one compilation failure remaining in the playground application, which occurs when building with Direct3D or SDL2 (but not GLFW):
d:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: d:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(main.o):(.text.startup+0xc0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
The same issue can be observed with MinGW-w64 as well:
D:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.3.0/../../../../i686-w64-mingw32/bin/ld.exe: D:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.3.0/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a(lib32_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@16'
I'm looking into #76 with cmake.
It looks like Android also needs SDL_MAIN_HANDLED defined for dumprwtree (not useful on Android because it is a cli tool, but good to know) and other targets.
I propose to do the following cmake change instead.
Instead of https://github.com/aap/librw/blob/b2ceadc9f2e478c5a470f625a0ee5b08ad12efb6/src/CMakeLists.txt#L160,
do:
target_compile_definitions(librw
PUBLIC
LIBRW_SDL2
SDL_MAIN_HANDLED
)
I guess something similar can be done in the premake script.
We should probably add a call to SDL_SetMainReady at the appropriate places.
See https://wiki.libsdl.org/SDL_SetMainReady
The SDL_MAIN_HANDLED changes have been separated into PR #83.
Can you please update this PR's title + description? This pr is not doing anything mingw related anymore. #87 adds mingw support (albeit not to the premake script)
Can you please update this PR's title + description? This pr is not doing anything mingw related anymore. #87 adds mingw support (albeit not to the premake script)
This PR is still necessary for the original MinGW (https://osdn.net/projects/mingw/).
Indeed. And with #87, no more WinMain linking errors.