-
Notifications
You must be signed in to change notification settings - Fork 99
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
Resolve WinMain linking issues with CMake #83
base: master
Are you sure you want to change the base?
Conversation
@@ -1,4 +1,5 @@ | |||
#ifdef _WIN32 | |||
#define SDL_MAIN_HANDLED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add a call to SDL_SetMainReady
in main
/WinMain
.
See https://wiki.libsdl.org/SDL_SetMainReady
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just checked the implementation of SDL_SetMainReady
.
It looks like SDL2main
is needed (for some platforms).
On e.g. Windows, it does something: https://github.com/libsdl-org/SDL/blob/main/src/main/windows/SDL_windows_main.c
Other platforms also use it: https://github.com/libsdl-org/SDL/tree/main/src/main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only seems to be needed on platforms that define SDL_MAIN_NEEDED
, while Windows defines SDL_MAIN_AVAILABLE
instead. For Windows, what SDL2main
provides is equivalent to what both the skeleton and MinGW already provide, so calling SDL_SetMainReady
shouldn't be necessary on Windows.
@@ -29,6 +28,8 @@ if(NOT SDL2_FOUND) | |||
endif() | |||
endif() | |||
|
|||
find_library(SDL2main_LIBRARY SDL2main) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use the SDL2main
library, so perhaps all logic related to SDL2main
can be removed from this cmake script?
98ad153
to
aaf2383
Compare
aaf2383
to
77753c8
Compare
c73688a
to
3d37d03
Compare
I created a branch on my fork that adds mingw CI with github actions: https://github.com/madebr/librw/tree/ga_mingw I find it weird that glfw works while d3d9 does not. |
I think it's because the GLFW backend has a standard |
@ccawley2011 |
This seems to work with the 64-bit mingw-w64 toolchain, but not with MinGW32 or the 32-bit mingw-w64 toolchain. |
I got it working for all configs. |
Thanks, I've tested the new changes and it works for me as well. I just have one additional suggested change for building with clang: index 7c7c27c..572e4b2 100644
--- a/cmake/UseStaticRuntime.cmake
+++ b/cmake/UseStaticRuntime.cmake
@@ -6,6 +6,8 @@ endif()
if(CMAKE_C_COMPILER_ID MATCHES "^GNU$")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++ -static")
+elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif()
if(WIN32)
Sure, go ahead. |
Thanks. I wasn't sure whether
I will post it in the coming days and tag you. |
Follow up to PR #77. SDL2 now works, but D3D9 is still broken.
Possibly related: