Reputation: 11
I was following Lazy Foo's tutorial for getting started with SDL.
So I followed all the instructions on the page and got some compilation error.
Here's the source code:
#include <iostream>
#include <SDL.h>
int main(int argc, char *argv[]){
if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
return 1;
}
SDL_Quit();
return 0;
}
Error 1 error LNK2019: unresolved external symbol _SDL_GetError referenced in function _SDL_main Error 2 error LNK2019: unresolved external symbol _SDL_Init referenced in function _SDL_main Error 3 error LNK2019: unresolved external symbol _SDL_Quit referenced in function _SDL_main Error 4 error LNK2019: unresolved external symbol _WinMain@16 referenced in __tmainCRTStartup
I've double checked to make sure my settings are correct.
Configuration Properties > VC++ Directories > Include Directories
C:\Users\Minkai\Documents\Visual Studio 2013\Projects\SDL2-2.0.3\include;$(IncludePath)
Configuration Properties > VC++ Directories > Library Directories
C:\Users\Minkai\Documents\Visual Studio 2013\Projects\SDL2-2.0.3\lib\x64;$(LibraryPath)
Configuration Properties > Linker > Input > Additional Dependencies
SDL2.lib;SDL2main.lib;%(AdditionalDependencies)
Configuration Properties > Linker > System > SubSystem I tried switching between Window and Console, doesn't work.
I put my SDL2.dll everywhere in the project just to make sure.
Some information:
Upvotes: 1
Views: 1587
Reputation:
In order to build an x64 SDL 2.0 application with VS2013, you need to create the platform and setup the following from your project properties:
"Project Properties" -> "Configuration Manager" -> "Active solution platform" drop-down menu and select "< New... >"
In the "New Solution Platform" dialog, choose "x64" in the "Type or select the new platform" drop-down menu
In the same dialog, leave "Copy settings from" on Win32, check "create new project platform" check-box
Note : Yet after these 3 steps, your VC++ Directories for this project will all be correctly set for the x64 flavor (check VC++ Directories in the project settings).
Make sure (or setup) your "C/C++" -> "General" -> "Additional Include Directories" contains a path to your "SDL/include" folder
Make sure (or setup) your "Linker" -> "General" -> "Additional Library Directories" contains a path to your "SDL/lib/x64" folder
Make sure (or setup) your "Linker" -> "Input" -> "Additional Dependencies" contains "SDL2.lib;" and "SDL2main.lib;"
Your sample should compile and link now. Make sure your executable can access "SDL/lib/x64/SDL2.dll" (eg. paste it next your exe) in order to run it
Upvotes: 0