mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-08 08:10:30 -10:00
build: use --subsystem,windows + main entry on MinGW (not -mwindows)
The previous two commits (SDL_MAIN_HANDLED indecdce0, dropping -lSDL*main in80f343b) stopped main being renamed to SDL_main and removed SDL's WinMain shim. That exposed the underlying issue: the MinGW build links with -mwindows, which selects crtexewin.o whose startup calls WinMain -- and RetroArch has no WinMain. With the SDL shim gone, the link now fails the other way: libmingw32.a(crtexewin.o): in function `main': undefined reference to `WinMain' RetroArch provides main() (retroarch.c) and creates its own Win32 window; it never had a WinMain. The MSVC and griffin builds already handle this with '-SUBSYSTEM:WINDOWS -ENTRY:mainCRTStartup': GUI subsystem (no console window) but an entry point that calls main(). Mirror that on GNU/MinGW by replacing -mwindows with -Wl,--subsystem,windows. This sets the PE subsystem to GUI (so no console window appears, same as before) while keeping the default crtexe.o startup, whose entry calls main(). The build then needs neither a WinMain nor SDL's WinMain shim, and the entry model matches the MSVC/griffin builds. RetroArch links the Win32 import libraries it uses explicitly (gdi32, ole32, winmm, comdlg32, dinput8, ...), so it does not depend on -mwindows to pull those in. Applies to both the C and CXX_BUILD MinGW builds (it is gated only on Win32, not on CXX_BUILD), unifying their entry-point handling. Completes the SDL entry-point series:decdce0/80f343b/ this.
This commit is contained in:
1 parent
80f343b494
commit
0bf5d29b05
1 file changed
+14
-1
@@ -108,7 +108,20 @@ ifeq ($(HAVE_DRMINGW), 1)
|
||||
endif
|
||||
|
||||
ifneq ($(findstring Win32,$(OS)),)
|
||||
LDFLAGS += -mwindows
|
||||
# Use the GUI subsystem (no console window) but keep the default
|
||||
# CRT entry that calls main(), rather than -mwindows which selects
|
||||
# crtexewin.o and requires a WinMain. RetroArch provides main() (in
|
||||
# retroarch.c) and its own Win32 window; it has no WinMain. This
|
||||
# mirrors the MSVC/griffin builds, which use
|
||||
# '-SUBSYSTEM:WINDOWS -ENTRY:mainCRTStartup' for the same effect.
|
||||
# Doing it this way means the build needs neither a hand-written
|
||||
# WinMain nor SDL's WinMain shim library (-lSDL*main), and it lets
|
||||
# the CXX_BUILD=1 link resolve (-mwindows -> WinMain -> SDL_main was
|
||||
# the chain that broke once main correctly stayed main). RetroArch
|
||||
# links the Win32 libraries it needs explicitly (gdi32, ole32,
|
||||
# winmm, comdlg32, ...), so it does not rely on -mwindows to pull
|
||||
# them in.
|
||||
LDFLAGS += -Wl,--subsystem,windows
|
||||
endif
|
||||
|
||||
ifneq ($(CXX_BUILD), 1)
|
||||
|
||||
Reference in new issue
Block a user