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 2777

Summary: (cmake) static linking causes __ftol2_sse multiple definitions error
Product: SDL Reporter: Wouter van Oortmerssen <aardappel>
Component: buildAssignee: Ryan C. Gordon <icculus>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: philipp.wiesemann
Version: HG 2.1   
Hardware: x86_64   
OS: Windows 7   

Description Wouter van Oortmerssen 2014-11-07 22:17:31 UTC
Two (possibly related) issue when trying to statically link SDL from cmake.

We use add_subdirectory() to pull in the SDL cmake file, as-is. Before that, I define SDL_SHARED to be OFF, since we only want static linking. This fails, because the SDL cmake file, right at the end, calls install() with the SDL2 target (as opposed to SDL2-static). To work around this, I redefined install() to do nothing (not wanting to modify SDL files).

Anyway, that now causes a multiple definition linker error on __ftol2_sse (note that our project actually uses SSE, this may be related?). I was able to get around this by definining:

add_definitions(-DHAVE_LIBC)
add_definitions(-DHAVE_STDIO_H)

I have no idea why these are off by default on Windows anyway.
Comment 1 Ryan C. Gordon 2015-02-19 04:14:56 UTC
(In reply to Wouter van Oortmerssen from comment #0)
> add_definitions(-DHAVE_LIBC)
> add_definitions(-DHAVE_STDIO_H)
> 
> I have no idea why these are off by default on Windows anyway.

They are off because on Windows, SDL doesn't use the C runtime library at all.

(except, apparently, for __ftol2_sse, which it shouldn't.)

I could have sworn we fixed this recently, but I don't know where at the moment.

--ryan.
Comment 2 Ryan C. Gordon 2015-02-19 05:22:16 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!