Resolve WinMain linking issues with CMake
Follow up to PR #77. SDL2 now works, but D3D9 is still broken.
Possibly related:
- https://forum.qt.io/topic/126534/qt-6-undefined-reference-to-winmain-on-mingw
- https://bugreports.qt.io/browse/QTBUG-93671
I created a branch on my fork that adds mingw CI with github actions: https://github.com/madebr/librw/tree/ga_mingw Github actions result at https://github.com/madebr/librw/actions/runs/1002476846 It has the behavior described in your initial comment: glfw/SDL2 works, d3d9 does not.
I find it weird that glfw works while d3d9 does not.
Their respective librw_skeletonlibraries are both providing a WinMain symbol in a static library.
What is different between them?
I find it weird that glfw works while d3d9 does not. Their respective
librw_skeletonlibraries are both providing aWinMainsymbol in a static library. What is different between them?
I think it's because the GLFW backend has a standard main() function that can be used with MinGW's default WinMain implementation, while the Win32 backend doesn't have one and the one in the SDL backend gets renamed when SDL_MAIN_HANDLED is not defined.
@ccawley2011
Please re-check my ga_mingw branch at https://github.com/madebr/librw/tree/ga_mingw
I got it working in a (so I believe) cleaner way by using linker options.
github action results at https://github.com/madebr/librw/actions/runs/1002584126
@ccawley2011 Please re-check my
ga_mingwbranch at https://github.com/madebr/librw/tree/ga_mingw I got it working in a (so I believe) cleaner way by using linker options. github action results at https://github.com/madebr/librw/actions/runs/1002584126
This seems to work with the 64-bit mingw-w64 toolchain, but not with MinGW32 or the 32-bit mingw-w64 toolchain.
@ccawley2011 Please re-check my
ga_mingwbranch at https://github.com/madebr/librw/tree/ga_mingw I got it working in a (so I believe) cleaner way by using linker options. github action results at https://github.com/madebr/librw/actions/runs/1002584126This 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. See https://github.com/madebr/librw/actions/runs/1006420251 for the logs. I also added the ability to switch between static and shared runtime (this also includes static SDL2/glfw). Is it okay for you if I open a pr with these commits (I have to rewrite the commit history)?
I got it working for all configs. See https://github.com/madebr/librw/actions/runs/1006420251 for the logs. I also added the ability to switch between static and shared runtime (this also includes static SDL2/glfw).
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)
Is it okay for you if I open a pr with these commits (I have to rewrite the commit history)?
Sure, go ahead.
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
Thanks. I wasn't sure whether -static also meant static libgcc and libstdc++
Is it okay for you if I open a pr with these commits (I have to rewrite the commit history)?
Sure, go ahead.
I will post it in the coming days and tag you.