We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2707 - Invalid linker flag XCClinker when compiling for statically MinGW
Summary: Invalid linker flag XCClinker when compiling for statically MinGW
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: build (show other bugs)
Version: HG 2.1
Hardware: x86 Windows (All)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.4, triage-2.0.4
Depends on:
Blocks:
 
Reported: 2014-08-27 13:11 UTC by Fredrik Hultin
Modified: 2015-05-26 15:13 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fredrik Hultin 2014-08-27 13:11:46 UTC
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.
Comment 1 Ryan C. Gordon 2015-02-19 05:22:20 UTC
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!
Comment 2 Ryan C. Gordon 2015-04-07 04:57:53 UTC
(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.
Comment 3 Ryan C. Gordon 2015-05-26 15:13:09 UTC
This patch is now https://hg.libsdl.org/SDL/rev/6d686d166a9e, thanks!

--ryan.