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 - (cmake) static linking causes __ftol2_sse multiple definitions error
Summary: (cmake) static linking causes __ftol2_sse multiple definitions error
Status: ASSIGNED
Alias: None
Product: SDL
Classification: Unclassified
Component: build (show other bugs)
Version: HG 2.1
Hardware: x86_64 Windows 7
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-07 22:17 UTC by Wouter van Oortmerssen
Modified: 2016-03-05 23:02 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 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!