| Summary: | Invalid linker flag XCClinker when compiling for statically MinGW | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Fredrik Hultin <noname> |
| Component: | build | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | icculus |
| Version: | HG 2.1 | Keywords: | target-2.0.4, triage-2.0.4 |
| Hardware: | x86 | ||
| OS: | Windows (All) | ||
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry if you got a lot of email from this. This is to help me sort through some bugs in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4, though! (sorry if you get a lot of copies of this email, I'm marking several bugs at once) Marking bugs for the (mostly) final 2.0.4 TODO list. This means we're hoping to resolve this bug before 2.0.4 ships if possible. In a perfect world, the open bug count with the target-2.0.4 keyword is zero when we ship. (Note that closing a bug report as WONTFIX, INVALID or WORKSFORME might still happen.) --ryan. This patch is now https://hg.libsdl.org/SDL/rev/6d686d166a9e, thanks! --ryan. |
OVERVIEW When compiling SDL2 statically for MinGW, the build system produces an sdl2-config and an sdl2.pc file with the invalid linker flag -XCClinker in it. In turn, this makes linking with SDL2 using pkg-config or sdl2-config impossible. STEPS TO REPRODUCE In Ubuntu 14.04 with mingw-w64 installed, and a clean SDL2 source tree... mkdir build && cd build ../configure --build=x86_64-linux-gnu --target=i686-w64-mingw32 --host=i686-w64-mingw32 --prefix=/usr/i686-w64-mingw32 --enable-static --disable-shared make sudo make install echo -e "#include <SDL.h>\nint main(int argc, char** argv){ return 0; }" > /tmp/sdl.c i686-w64-mingw32-gcc $(./sdl2-config --cflags --static-libs) /tmp/sdl.c -o /tmp/sdl.exe EXPECTED RESULTS A working binary. ACTUAL RESULTS i686-w64-mingw32-gcc: error: unrecognized command line option ‘-XCClinker’ BUILD DATE & HARDWARE SDL2 hg cloned from https://hg.libsdl.org/SDL, Wed Aug 27 Linux fredrik-xps13 3.13.0-34-generic #60-Ubuntu SMP Wed Aug 13 15:45:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux Ubuntu 14.04.1 LTS i686-w64-mingw32-gcc (GCC) 4.8.2 SUGGESTED FIX I'm not sure what the purpose of the flag is (used to be?) but when googling for it I find mainly two things: 1) some discussion on the GCC board from 2002 and 2) people having trouble compiling SDL2 with MinGW and removing XCClinker from the build scripts. It would probably be safe to simply remove the flag from configure.in, like so: --- a/configure.in Mon Aug 25 10:55:54 2014 -0700 +++ b/configure.in Wed Aug 27 15:04:54 2014 +0200 @@ -3012,7 +3012,7 @@ else LIBUUID=-luuid fi - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion $LIBUUID -XCClinker -static-libgcc" + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion $LIBUUID -static-libgcc" # The Windows platform requires special setup VERSION_SOURCES="$srcdir/src/main/windows/*.rc" SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c" This solves the issue on my machine.