The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL 2.0 compilation with Visual Studio 2015
rotanov


Joined: 27 Sep 2015
Posts: 9
I'm unable to compile SDL 2.0 with Visual Studio 2015 with the following link errors:

Quote:

4>MSVCRTD.lib(_init_.obj) : error LNK2019: unresolved external symbol __CrtDbgReport referenced in function __CRT_RTC_INIT [D:\dev\engine\build_vs2015\sdl\src\sdl-build\SDL2.vcxproj]
4>MSVCRTD.lib(_init_.obj) : error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function __CRT_RTC_INITW [D:\dev\engine\build_vs2015\sdl\src\sdl-build\SDL2.vcxproj]
4>MSVCRTD.lib(_ftol3_.obj) : error LNK2019: unresolved external symbol __except1 referenced in function __ftol3_except [D:\dev\engine\build_vs2015\sdl\src\sdl-build\SDL2.vcxproj]
4>MSVCRTD.lib(_error_.obj) : error LNK2019: unresolved external symbol ___stdio_common_vsprintf_s referenced in function __vsprintf_s_l [D:\dev\engine\build_vs2015\sdl\src\sdl-build\SDL2.vcxproj]
4>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol __wmakepath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath@@YAHPB_WPA_WI@Z) [D:\dev\engine\build_vs2015\sdl\src\sdl-build\SDL2.vcxproj]
4>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol __wsplitpath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath@@YAHPB_WPA_WI@Z) [D:\dev\engine\build_vs2015\sdl\src\sdl-build\SDL2.vcxproj]
4>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol _wcscpy_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath@@YAHPB_WPA_WI@Z) [D:\dev\engine\build_vs2015\sdl\src\sdl-build\SDL2.vcxproj]
4>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol ___vcrt_GetModuleFileNameW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPAUHINSTANCE__@@XZ) [D:\dev\engine\build_vs2015\sdl\src\sdl-build\SDL2.vcxproj]
4>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol ___vcrt_GetModuleHandleW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPAUHINSTANCE__@@XZ) [D:\dev\engine\build_vs2015\sdl\src\sdl-build\SDL2.vcxproj]
4>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol ___vcrt_LoadLibraryExW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPAUHINSTANCE__@@XZ) [D:\dev\engine\build_vs2015\sdl\src\sdl-build\SDL2.vcxproj]
4>MSVCRTD.lib(_chandler4gs_.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4 [D:\dev\engine\build_vs2015\sdl\src\sdl-build\SDL2.vcxproj]
rotanov


Joined: 27 Sep 2015
Posts: 9
The first post errors occurred on Windows 7 system with Visual Studio 2015.
On another system (Windows 8 Visual Studio 2015) I got lots of those:

Quote:

Severity Code Description Project File Line
Error C2011 '_XINPUT_BATTERY_INFORMATION': 'struct' type redefinition [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl d:\dev\engine\3rd\sdl\src\core\windows\SDL_xinput.h 122


Maybe related to this commit https://github.com/spurious/SDL-mirror/commit/bf785c766bdcdf6ad498123ae80d132a7192b10d
DLudwig


Joined: 09 Feb 2012
Posts: 179
rotanov wrote:
The first post errors occurred on Windows 7 system with Visual Studio 2015.
On another system (Windows 8 Visual Studio 2015) I got lots of those:

Quote:

Severity Code Description Project File Line
Error C2011 '_XINPUT_BATTERY_INFORMATION': 'struct' type redefinition [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl d:\dev\engine\3rd\sdl\src\core\windows\SDL_xinput.h 122


Maybe related to this commit https://github.com/spurious/SDL-mirror/commit/bf785c766bdcdf6ad498123ae80d132a7192b10d


I can't speak definitively on the Win7 error. It kind-of looks like you might be mixing debug-mode and release-mode SDL dlls, but I could be wrong there.

On the Win8 error, that looks like it might be a bug in SDL, one where the commit you referenced (also referenced on the official SDL hg server, via https://hg.libsdl.org/SDL/rev/26b595dea221 ), caused builds against certain versions of the Windows SDK to fail. I get the same error on WinRT, after having updated one of my own repos to the latest SDL code (from hg.libsdl.org). From briefly looking at the copy of the Windows SDK I have, it looks like the Win8+ SDKs have a few identical type declarations, which MSVC is unable to reliably resolve.

If I can find time in the next few weeks, I can take a stab at providing a patch (to Sam, Ryan, etc.), but make no guarantees. I don't have an actively-working Win7 dev system anymore though, so I wouldn't be able to test building there. Neutral

-- David L.
DLudwig


Joined: 09 Feb 2012
Posts: 179
DLudwig wrote:
If I can find time in the next few weeks, I can take a stab at providing a patch (to Sam, Ryan, etc.), but make no guarantees. I don't have an actively-working Win7 dev system anymore though, so I wouldn't be able to test building there. Neutral


I came up with a quick, largely-untested patch just now. I've only tested it on WinRT though. Feel free to give it a shot wherever. I suspect it may work on Win32 + MSVC 2015, but I make no guarantees on that.

https://www.dropbox.com/s/x3dgwc0sw6cuksa/SDL_XInput_build_fix_candidate_for_Win8x.patch?dl=1

Cheers,
-- David L.
Bandock


Joined: 10 Oct 2013
Posts: 11
Yeah, best way to fix it is to compile the source yourself since Visual Studio 2015 made changes that broke several Visual Studio builds (anything prior to VS2015 that is). I know because I had to contend with errors like that popping up.

Hopefully, a precompiled Visual Studio 2015 build becomes available for those who don't want to compile it themselves.
bjadams


Joined: 15 Oct 2015
Posts: 11
+1 for a precompiled VS2015 for newcommers like me to get things started smoothly

then when one gets more comfortable & experienced with SDL we can build the lib ourselves
Bandock


Joined: 10 Oct 2013
Posts: 11
I've decided to go ahead and redistribute a working Visual Studio 2015 Multi-Threaded Build (32-bit x86). It is actually compiled as a DLL (only tweaked the code generation setting), but should not require any Visual C++ 2015 Runtime Package to run.

Of course, if anyone wants me to compile a Multi-Threaded DLL build that requires the Runtime Package, let me know.

Link: https://dl.dropboxusercontent.com/u/24250760/SDL/SDL-2.0.3%20VS2015%20MT%20Build%20%28x86%29.zip

I provided the "COPYING.txt" file found with the source code distribution to make sure original credit was given.
Bandock


Joined: 10 Oct 2013
Posts: 11
Addendum to my previous post: It currently uses the current stable build provided on the website. Not providing a SDL 2.0.4 build yet.
Reavenk


Joined: 09 Nov 2015
Posts: 2
I had a lot of the same linker errors in Visual Studio 2015.

After reading
http://stackoverflow.com/questions/31867018/unresolved-external-symbol-except-handler4-common-in-visual-studio-2015
and
http://blogs.msdn.com/b/vcblog/archive/2015/03/03/introducing-the-universal-crt.aspx

I added msvcrtd.lib, vcruntimed.lib and ucrtd.lib explicitly to my libs list and it worked for me.
(I was using the source from OGRE3D's dependency libraries' trunk)
DLudwig


Joined: 09 Feb 2012
Posts: 179
FYI, this particular bug, whereby there's a build error in SDL_xinput.h, should now be fixed (in the latest code from https://hg.libsdl.org/SDL).

Are you still seeing the other build errors?

-- David L.


rotanov wrote:
The first post errors occurred on Windows 7 system with Visual Studio 2015.
On another system (Windows 8 Visual Studio 2015) I got lots of those:

Quote:

Severity Code Description Project File Line
Error C2011 '_XINPUT_BATTERY_INFORMATION': 'struct' type redefinition [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl d:\dev\engine\3rd\sdl\src\core\windows\SDL_xinput.h 122


Maybe related to this commit https://github.com/spurious/SDL-mirror/commit/bf785c766bdcdf6ad498123ae80d132a7192b10d
rotanov


Joined: 27 Sep 2015
Posts: 9
The error with `_XINPUT_BATTERY_INFORMATION` is gone now. However I'm still experiencing previous build errors, listed below for debug and release builds respectively.

> It kind-of looks like you might be mixing debug-mode and release-mode SDL dlls, but I could be wrong there.

Nope, I double checked this. 2013 is fine, 2015 results in errors. I'm using SDL as git submodule in my project therefore I'm not able to change its cmake makefiles. I'm including it in my cmake file with `ExternalProject_Add`. And I'm not sure if I can add required static libraries externally to SDL cmake project.

Release build errors:

Code:

Severity  Code  Description Project File  Line
Error LNK2019 unresolved external symbol __except1 referenced in function __ftol3_except [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRT.lib(_ftol3_.obj) 1
Error LNK2019 unresolved external symbol __except1 referenced in function __ftol3_except [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRT.lib(_ftol3_.obj) 1
Error LNK1120 1 unresolved externals [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\sdl\src\sdl-build\Release\SDL2.dll  1
Error LNK1120 1 unresolved externals [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\sdl\src\sdl-build\Release\SDL2.dll  1
Error C1083 Cannot open include file: 'SDL.h': No such file or directory  engine  D:\dev\engine\src\main.cpp  3



Debug build errors:

Code:

Severity  Code  Description Project File  Line
Error LNK2019 unresolved external symbol __except_handler4_common referenced in function __except_handler4 [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRTD.lib(_chandler4gs_.obj)  1
Error LNK2019 unresolved external symbol __except_handler4_common referenced in function __except_handler4 [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRTD.lib(_chandler4gs_.obj)  1
Error LNK2019 unresolved external symbol ___stdio_common_vsprintf_s referenced in function __vsprintf_s_l [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj]  sdl D:\dev\engine\build\MSVCRTD.lib(_error_.obj)  1
Error LNK2019 unresolved external symbol ___stdio_common_vsprintf_s referenced in function __vsprintf_s_l [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj]  sdl D:\dev\engine\build\MSVCRTD.lib(_error_.obj)  1
Error LNK2019 unresolved external symbol __except1 referenced in function __ftol3_except [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRTD.lib(_ftol3_.obj)  1
Error LNK2019 unresolved external symbol __except1 referenced in function __ftol3_except [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRTD.lib(_ftol3_.obj)  1
Error LNK2019 unresolved external symbol __CrtDbgReport referenced in function __CRT_RTC_INIT [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj]  sdl D:\dev\engine\build\MSVCRTD.lib(_init_.obj) 1
Error LNK2019 unresolved external symbol __CrtDbgReportW referenced in function __CRT_RTC_INITW [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj]  sdl D:\dev\engine\build\MSVCRTD.lib(_init_.obj) 1
Error LNK2019 unresolved external symbol __CrtDbgReport referenced in function __CRT_RTC_INIT [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj]  sdl D:\dev\engine\build\MSVCRTD.lib(_init_.obj) 1
Error LNK2019 unresolved external symbol __CrtDbgReportW referenced in function __CRT_RTC_INITW [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj]  sdl D:\dev\engine\build\MSVCRTD.lib(_init_.obj) 1
Error LNK2019 unresolved external symbol __wmakepath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath@@YAHPB_WPA_WI@Z) [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRTD.lib(_pdblkup_.obj)  1
Error LNK2019 unresolved external symbol __wsplitpath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath@@YAHPB_WPA_WI@Z) [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj]  sdl D:\dev\engine\build\MSVCRTD.lib(_pdblkup_.obj)  1
Error LNK2019 unresolved external symbol _wcscpy_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath@@YAHPB_WPA_WI@Z) [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRTD.lib(_pdblkup_.obj)  1
Error LNK2019 unresolved external symbol ___vcrt_GetModuleFileNameW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPAUHINSTANCE__@@XZ) [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRTD.lib(_pdblkup_.obj)  1
Error LNK2019 unresolved external symbol ___vcrt_GetModuleHandleW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPAUHINSTANCE__@@XZ) [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRTD.lib(_pdblkup_.obj)  1
Error LNK2019 unresolved external symbol ___vcrt_LoadLibraryExW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPAUHINSTANCE__@@XZ) [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRTD.lib(_pdblkup_.obj)  1
Error LNK2019 unresolved external symbol __wmakepath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath@@YAHPB_WPA_WI@Z) [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRTD.lib(_pdblkup_.obj)  1
Error LNK2019 unresolved external symbol __wsplitpath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath@@YAHPB_WPA_WI@Z) [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj]  sdl D:\dev\engine\build\MSVCRTD.lib(_pdblkup_.obj)  1
Error LNK2019 unresolved external symbol _wcscpy_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath@@YAHPB_WPA_WI@Z) [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRTD.lib(_pdblkup_.obj)  1
Error LNK2019 unresolved external symbol ___vcrt_GetModuleFileNameW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPAUHINSTANCE__@@XZ) [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRTD.lib(_pdblkup_.obj)  1
Error LNK2019 unresolved external symbol ___vcrt_GetModuleHandleW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPAUHINSTANCE__@@XZ) [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRTD.lib(_pdblkup_.obj)  1
Error LNK2019 unresolved external symbol ___vcrt_LoadLibraryExW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPAUHINSTANCE__@@XZ) [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl D:\dev\engine\build\MSVCRTD.lib(_pdblkup_.obj)  1
Error LNK1120 11 unresolved externals [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj]  sdl D:\dev\engine\build\sdl\src\sdl-build\Debug\SDL2.dll  1
Error LNK1120 11 unresolved externals [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj]  sdl D:\dev\engine\build\sdl\src\sdl-build\Debug\SDL2.dll  1
Error C1083 Cannot open include file: 'SDL.h': No such file or directory  engine  D:\dev\engine\src\main.cpp  3



DLudwig wrote:
FYI, this particular bug, whereby there's a build error in SDL_xinput.h, should now be fixed (in the latest code from https://hg.libsdl.org/SDL).

Are you still seeing the other build errors?

-- David L.


rotanov wrote:
The first post errors occurred on Windows 7 system with Visual Studio 2015.
On another system (Windows 8 Visual Studio 2015) I got lots of those:

Quote:

Severity Code Description Project File Line
Error C2011 '_XINPUT_BATTERY_INFORMATION': 'struct' type redefinition [D:\dev\engine\build\sdl\src\sdl-build\SDL2.vcxproj] sdl d:\dev\engine\3rd\sdl\src\core\windows\SDL_xinput.h 122


Maybe related to this commit https://github.com/spurious/SDL-mirror/commit/bf785c766bdcdf6ad498123ae80d132a7192b10d
DLudwig


Joined: 09 Feb 2012
Posts: 179
rotanov wrote:
The error with `_XINPUT_BATTERY_INFORMATION` is gone now. However I'm still experiencing previous build errors, listed below for debug and release builds respectively.

> It kind-of looks like you might be mixing debug-mode and release-mode SDL dlls, but I could be wrong there.

Nope, I double checked this. 2013 is fine, 2015 results in errors. I'm using SDL as git submodule in my project therefore I'm not able to change its cmake makefiles. I'm including it in my cmake file with `ExternalProject_Add`. And I'm not sure if I can add required static libraries externally to SDL cmake project.


Sorry to hear that, and unfortunately I don't think I can be of much help here. I am unfamiliar with SDL's CMake setup, or CMake in general. I wouldn't be surprised if there was either a bug in SDL's CMake files, or perhaps CMake + VS2015, but am uncertain of this.

-- David L.
rotanov


Joined: 27 Sep 2015
Posts: 9
Reavenk wrote:
I had a lot of the same linker errors in Visual Studio 2015.

After reading
http://stackoverflow.com/questions/31867018/unresolved-external-symbol-except-handler4-common-in-visual-studio-2015
and
http://blogs.msdn.com/b/vcblog/archive/2015/03/03/introducing-the-universal-crt.aspx

I added msvcrtd.lib, vcruntimed.lib and ucrtd.lib explicitly to my libs list and it worked for me.
(I was using the source from OGRE3D's dependency libraries' trunk)


This works for me. vc project not having its default libraries linked by default is somehow strange. It would be nice as a workaround or as a solution to have those added via CMakeLists.txt. (For VS2015+)

For debug dll build it was enough to link to ucrtd.lib;vcruntimed.lib and for release dll one: vcruntime.lib
Bandock


Joined: 10 Oct 2013
Posts: 11
I have now taken down the build I put up since 2.0.4 is now available and no longer requires anytime C Runtime Package.

I even tested it myself using the provided development libraries on the main website and found it to be the compatible with Multithreaded.
rotanov


Joined: 27 Sep 2015
Posts: 9
Yeah, there was a commit with fix to cmake files. I tested it a couple of days ago and it works for me just fine.