Trying to compile SDL2 source code inside of my project results in 102 unresolved external symbol errors

I have copied of all of the SDL2 source code (no libraries) into a Visual Studio c++ project. Whenever I try to compile, The build fails with 102 unresolved external symbols. All of the functions that are causing this error seem to have the extern keyword in them. Has anyone ever had this problem? How can I fix it? This is the output of the build.

LNK2001	unresolved external symbol _SDL_Delay_REAL	SDL_spinlock.obj	1	
LNK2001	unresolved external symbol _SDL_UnloadObject_REAL	SDL_directsound.obj	1	
LNK2001	unresolved external symbol _SDL_LoadObject_REAL	SDL_directsound.obj	1	
LNK2001	unresolved external symbol _SDL_LoadFunction_REAL	SDL_directsound.obj	1	
LNK2001	unresolved external symbol _WINMM_bootstrap	SDL_audio.obj	1	
LNK2001	unresolved external symbol _SDL_UnlockMutex_REAL	SDL_audio.obj	1	
LNK2001	unresolved external symbol _SDL_CreateMutex_REAL	SDL_audio.obj	1	
LNK2001	unresolved external symbol _SDL_ThreadID_REAL	SDL_audio.obj	1	
LNK2001	unresolved external symbol _SDL_LockMutex_REAL	SDL_audio.obj	1	
LNK2001	unresolved external symbol _SDL_DestroyMutex_REAL	SDL_audio.obj	1	
LNK2001	unresolved external symbol _WASAPI_bootstrap	SDL_audio.obj	1	
LNK2001	unresolved external symbol _SDL_GetPerformanceFrequency_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_GetTicks_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_SetWindowsMessageHook_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_DestroySemaphore_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_SemTryWait_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_SemWait_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_SemValue_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_RegisterApp_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_GetPerformanceCounter_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_DXGIGetOutputInfo_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_Direct3D9GetAdapterIndex_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_SemPost_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_CreateSemaphore_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_SemWaitTimeout_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_GetPrefPath_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_GetBasePath_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_UnregisterApp_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_TryLockMutex_REAL	SDL_dynapi.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticUnpause	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticMouse	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_JoystickSameHaptic	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticStopAll	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_NumHaptics	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticInit	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticDestroyEffect	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticQuit	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticOpenFromJoystick	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticSetAutocenter	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticGetEffectStatus	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticNewEffect	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticName	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_JoystickIsHaptic	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticOpen	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticPause	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticClose	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticRunEffect	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticStopEffect	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticSetGain	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_HapticUpdateEffect	SDL_haptic.obj	1	
LNK2001	unresolved external symbol _GUID_SawtoothDown	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_RzAxis	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_Damper	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_SawtoothUp	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_RemoveHapticDevice	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _CLSID_DirectInput8	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _IID_IDirectInput8W	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_Friction	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_RyAxis	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_ZAxis	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _IID_IDirectInputDevice8W	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _SDL_HelperWindow	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_XAxis	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_AddHapticDevice	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_RampForce	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_Triangle	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_CustomForce	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_ConstantForce	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_RxAxis	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_YAxis	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_Sine	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _SDL_hapticlist	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_Spring	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _GUID_Inertia	SDL_dinputhaptic.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_AddJoystickDevice	SDL_dinputjoystick.obj	1	
LNK2001	unresolved external symbol _GUID_POV	SDL_dinputjoystick.obj	1	
LNK2001	unresolved external symbol _GUID_Slider	SDL_dinputjoystick.obj	1	
LNK2001	unresolved external symbol _SYS_Joystick	SDL_dinputjoystick.obj	1	
LNK2001	unresolved external symbol __imp__joyGetPosEx@8	SDL_mmjoystick.obj	1	
LNK2001	unresolved external symbol __imp__joyGetDevCapsA@12	SDL_mmjoystick.obj	1	
LNK2001	unresolved external symbol __imp__joyGetNumDevs@0	SDL_mmjoystick.obj	1	
LNK2001	unresolved external symbol _SDL_GetPowerInfo_Windows	SDL_power.obj	1	
LNK2001	unresolved external symbol _MatrixRotationZ	SDL_render_d3d.obj	1	
LNK2001	unresolved external symbol _MatrixMultiply	SDL_render_d3d.obj	1	
LNK2001	unresolved external symbol _MatrixIdentity	SDL_render_d3d.obj	1	
LNK2001	unresolved external symbol _MatrixTranslation	SDL_render_d3d.obj	1	
LNK2001	unresolved external symbol _D3D_LoadDLL	SDL_render_d3d.obj	1	
LNK2001	unresolved external symbol _GLES2_RenderDriver	SDL_render.obj	1	
LNK2001	unresolved external symbol _GL_RenderDriver	SDL_render.obj	1	
LNK2001	unresolved external symbol _SDL_HelperWindowDestroy	SDL.obj	1	
LNK2001	unresolved external symbol _SDL_TicksQuit	SDL.obj	1	
LNK2001	unresolved external symbol _SDL_HelperWindowCreate	SDL.obj	1	
LNK2001	unresolved external symbol _SDL_TicksInit	SDL.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_DetachThread	SDL_thread.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_SetThreadPriority	SDL_thread.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_SetupThread	SDL_thread.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_WaitThread	SDL_thread.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_SetTLSData	SDL_thread.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_GetTLSData	SDL_thread.obj	1	
LNK2001	unresolved external symbol _SDL_SYS_CreateThread	SDL_thread.obj	1	
LNK2001	unresolved external symbol _WIN_ShowMessageBox	SDL_video.obj	1	
LNK2001	unresolved external symbol _WINDOWS_bootstrap	SDL_video.obj	1	
LNK1120	102 unresolved externals	GameEngine.exe	1	

I am using Visual Studio 2015

Does anyone have any idea what causes this? I have no idea what to do.

if you want to build SDL2 yourself, use the visual studio solution in VisualC/

if you just want to use it, set it up like described on http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/msvsnet2010u/index.php

@Daniel_Gibson I think you might have misunderstood, I’m building SDL inside of my project. Meaning, all of the SDL source code is in the same solution as the rest of the code. I would prefer not to build it separately, but if that is what I have to do, I will.

Now it’s down to 36 unresolved externals. I don’t know what I did, but it changed something.

It seems that all of these errors are stemming from problems with the dynamic API. These are the errors that I’m getting from there.

Severity	Code	Description	Project	File	Line	Suppression State
Error (active)		expected an expression	GameEngine	c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi.c	137	
Error (active)		declaration is incompatible with "SDL_DYNAPIFN_SDL_SetError SDL_SetError" (declared at line 34 of "c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi_procs.h")	GameEngine	c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi.c	164	
Error (active)		declaration is incompatible with "int __cdecl SDL_SetError(const char *fmt, ...)" (declared at line 164 of "c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi.c")	GameEngine	c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi_procs.h	34	
Error (active)		declaration is incompatible with "void __cdecl SDL_Log(const char *fmt, ...)" (declared at line 164 of "c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi.c")	GameEngine	c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi_procs.h	35	
Error (active)		declaration is incompatible with "void __cdecl SDL_LogVerbose(int category, const char *fmt, ...)" (declared at line 164 of "c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi.c")	GameEngine	c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi_procs.h	36	
Error (active)		declaration is incompatible with "void __cdecl SDL_LogDebug(int category, const char *fmt, ...)" (declared at line 164 of "c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi.c")	GameEngine	c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi_procs.h	37	
Error (active)		declaration is incompatible with "void __cdecl SDL_LogInfo(int category, const char *fmt, ...)" (declared at line 164 of "c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi.c")	GameEngine	c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi_procs.h	38	
Error (active)		declaration is incompatible with "void __cdecl SDL_LogWarn(int category, const char *fmt, ...)" (declared at line 164 of "c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi.c")	GameEngine	c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi_procs.h	39	
Error (active)		declaration is incompatible with "void __cdecl SDL_LogError(int category, const char *fmt, ...)" (declared at line 164 of "c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi.c")	GameEngine	c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi_procs.h	40	
Error (active)		declaration is incompatible with "void __cdecl SDL_LogCritical(int category, const char *fmt, ...)" (declared at line 164 of "c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi.c")	GameEngine	c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi_procs.h	41	
Error (active)		declaration is incompatible with "void __cdecl SDL_LogMessage(int category, SDL_LogPriority priority, const char *fmt, ...)" (declared at line 164 of "c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi.c")	GameEngine	c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi_procs.h	42	
Error (active)		declaration is incompatible with "int __cdecl SDL_sscanf(const char *buf, const char *fmt, ...)" (declared at line 164 of "c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi.c")	GameEngine	c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi_procs.h	43	
Error (active)		declaration is incompatible with "int __cdecl SDL_snprintf(char *buf, size_t maxlen, const char *fmt, ...)" (declared at line 164 of "c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi.c")	GameEngine	c:\Users\LTP\Desktop\Game Engine\GameEngine\SDL\src\dynapi\SDL_dynapi_procs.h	44

I can’t get this to work, is it possible to just disable the dynamic api?