![]() |
Static linking SDL2 with /MT in MSVC. | ![]() |
![]() |
Static linking SDL2 with /MT in MSVC. | ![]() |
Vittorio Giovara
Guest
![]() |
![]() |
This is quite interesting, should definitely be on the wiki
![]() Vittorio On 17/ott/2013, at 20:56, rainwarrior wrote:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
||||||||||||
|
![]() |
Static linking SDL2 with /MT in MSVC. | ![]() |
Norfanin
![]() |
![]() |
rainwarrior wrote:
You don't need to edit the source, just add HAVE_LIBC to the preprocesser definitions when building SDL with the Visual C runtime library. Withou that, SDL builds without a C runtime library dependency and some symbols are necessary to satisfy the Microsoft compiler.
It's apparently expected that SDL as a dynamic library won't ever call _chkstk. When linking statically, the C runtime library is required. See https://bugzilla.libsdl.org/show_bug.cgi?id=2087 . _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
||||||||||||||
|
![]() |
Static linking SDL2 with /MT in MSVC. | ![]() |
Norfanin
![]() |
![]() |
Oh, and if you still build 2.0.0 you might want to check out the new
SDL_config_windows.h. It has some changes that will correctly set the HAVE_X defines for MSVC 2010 and 2012. http://hg.libsdl.org/SDL/raw-file/a87057441d01/include/SDL_config_windows.h _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
||||||||||
|
![]() |
![]() |
rainwarrior
![]() |
![]() |
Ah, thanks.
Using that updated SDL_config_windows.h and adding #define HAVE_LIBC at the top of it, everything seems to build fine, and there's no longer a need to remove the empty _chkstk implementation. |
||||||||||
|
![]() |
![]() |
rainwarrior
![]() |
![]() |
Would it be appropriate to add this to SDL_config_windows.h?
|
||||||||||||
|
![]() |
Static linking SDL2 with /MT in MSVC. | ![]() |
Norfanin
![]() |
![]() |
This would force HAVE_LIBC for everyone that didn't create the Visual Studio project in a very specific way. It also seems to be a MFC related define and doesn't look like it applies in this context. Unless there's something I'm missing? _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
||||||||||||
|
![]() |
![]() |
rainwarrior
![]() |
![]() |
_WINDLL is automatically defined by the MSVC compiler when building as a DLL (and conversely it is not defined when building as a static library).
I don't think MFC has anything to do with it. What do you mean by that? Also, what do you mean by creating the visual studio project in a specific way? If you set the Configuration Type under general properties to DLL, the _WINDLL define is automatically part of the build command. As far as I know there isn't a way to do this wrong, you're either building a DLL or you're not, and this is the define that indicates this. Am I mistaken about that? |
||||||||||
|
![]() |
![]() |
rainwarrior
![]() |
![]() |
To be more specific, it's added to the compile command line by visual studio, not directly by the compiler (the compiler doesn't have a special flag for targeting a DLL). There is information about it here:
http://msdn.microsoft.com/en-us/library/vstudio/8x480de8%28v=vs.100%29.aspx The only way I think a user could get it wrong is to manually define _WINDLL for a non-DLL build? |
||||||||||
|
![]() |
Static linking SDL2 with /MT in MSVC. | ![]() |
Norfanin
![]() |
![]() |
rainwarrior wrote:
Oh, yeah. Now I see it. I guess I didn't look careful enough and failed at using google properly. It seems to add it once with a direct definition and then with the %(PreprocessorDefinitions) macro. It's an IDE specific thing, but if it works... _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
||||||||||||
|