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 3092

Summary: Statically link sdl2 with /MT for msvc [PATCH]
Product: SDL Reporter: Martin Gerhardy <martin.gerhardy>
Component: buildAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus, mike.linford.reg
Version: HG 2.1   
Hardware: x86_64   
OS: Linux   
Attachments: _MT guard

Description Martin Gerhardy 2015-08-12 15:11:28 UTC
According to https://msdn.microsoft.com/de-de/library/2kzt1wy3%28v=vs.120%29.aspx when one is using /MT for msvc compilations the libcmt.lib is already linked to the binary. This lib includes the symbol that is now guarded (see attached patch) by the #ifndef _MT.
Comment 1 Martin Gerhardy 2015-08-12 15:12:09 UTC
Created attachment 2238 [details]
_MT guard
Comment 3 Sam Lantinga 2016-01-02 18:26:13 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/4de94185790e
Comment 4 Sam Lantinga 2016-01-02 19:19:40 UTC
This commit broke the Visual Studio build on buildbot, which apparently defines _MT but doesn't include that symbol.
Comment 5 Martin Gerhardy 2016-01-02 20:26:46 UTC
What msvc version is running there? I tested it with vs2015
Comment 6 Ryan C. Gordon 2016-01-02 20:31:27 UTC
(In reply to Martin Gerhardy from comment #5)
> What msvc version is running there? I tested it with vs2015

The buildbot does builds with VS2008 and VS2010 at the moment.

This was the VS2008 error messages for this case:

https://buildbot.libsdl.org/builders/sdl-visualstudio/builds/2620/steps/compile/logs/errors

I don't personally know how to best resolve this (among other options: is it time to drop VS2008?).

--ryan.
Comment 7 Mike Linford 2016-10-16 20:48:07 UTC
I'm also having trouble statically linking SDL2 on Visual Studio 2015 with /MT. My symptom is that memcpy is being defined twice.

I was able to fix it in on my machine by changing line 282 of SDL_stdlib.c to:

#if (_MSC_VER >= 1400) && defined(_WIN64) && !defined(_DEBUG) && !(_MSC_VER >= 1900 && defined(_MT))
Comment 8 Sam Lantinga 2016-10-18 04:47:58 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/d8a72d273dd2
Comment 9 Mike Linford 2016-10-19 01:49:03 UTC
You're welcome. Looks like 2.0.5 is coming up. Think this'll make it in?
Comment 10 Sam Lantinga 2016-10-19 06:03:59 UTC
Yes, it's already in. :)
Comment 11 Sam Lantinga 2017-08-12 23:26:48 UTC
This is resolved.