Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation with MinGW32 #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ccawley2011
Copy link
Contributor

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'

@madebr
Copy link
Contributor

madebr commented Jun 30, 2021

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

target_compile_definitions(librw PUBLIC LIBRW_SDL2)
,
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

@ccawley2011
Copy link
Contributor Author

The SDL_MAIN_HANDLED changes have been separated into PR #83.

@madebr
Copy link
Contributor

madebr commented Jul 9, 2021

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)

@ccawley2011
Copy link
Contributor Author

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/).

@madebr
Copy link
Contributor

madebr commented Jul 9, 2021

Indeed.
And with #87, no more WinMain linking errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants