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 1619 - static linking in windows causes _allmul to break
Summary: static linking in windows causes _allmul to break
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: build (show other bugs)
Version: HG 2.0
Hardware: x86 Windows (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-10 11:59 UTC by zeromus
Modified: 2013-05-16 03:45 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 zeromus 2012-10-10 11:59:01 UTC
In r1901, #define HAVE_LIBC was removed from SDL_config_windows.h. this causes an _allmul to get built which mismatches the calling convention MSVC expects. This code gets used if you static link SDL and breaks the program due to caller and callee convention disagreement. I'm not sure how SDL itself works under the circumstances. This was strange and somewhat difficult to debug.

Ostensibly, this change was made "to fix building with visual c++ 2005 express edition". I just built SDL hg latest in vc++ 2005 express without that change. The stock SDL doesnt build in that environment anyway without reconfiguration due to the msvc2005 windows SDK being too old and lacking IME parts.

When doing this, one is obliged to add 
#define _USE_MATH_DEFINES
in the same place or else you will run into a lot of files missing M_PI in any version of visual studio. I'm unsure what the complete ramifications of this would be, but I think it's pretty benign.

I suggest replacing SDL_config_windows.h
//#define HAVE_LIBC 1
with
#define HAVE_LIBC 1
#define _USE_MATH_DEFINES 1
Comment 1 Muf 2013-05-12 19:19:54 UTC
Can this please be merged ASAP? I just spent a day trying to figure this out before finding this bugzilla entry. I was not pleased to see there's been a fix since last October, that still hasn't been merged. I can confirm the proposed changes fix the problem, although to get rid of compiler warnings I had to comment the following lines:

#define HAVE_STRTOLL 1
#define HAVE_SSCANF 1
#define HAVE_COPYSIGN 1
#define HAVE_SCALBN 1
Comment 2 Sam Lantinga 2013-05-16 03:45:56 UTC
Colin Barrett fixed the _allmul issue in bug 1846.

By default SDL builds without the C runtime to avoid MSVCRT incompatibilities and manifest issues.