Minkai Ong
Minkai Ong

Reputation: 11

SDL 2.0 build error using VS

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:

  1. Using the latest SDL SDL2-devel-2.0.3-VC.zip
  2. IDE is Microsoft Visual Studio Express 2013 for Windows Desktop Version 12.0.31101.00 Update 4
  3. OS is 64-bit Windows 8.1

Upvotes: 1

Views: 1587

Answers (1)

user1608171
user1608171

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:

  1. "Project Properties" -> "Configuration Manager" -> "Active solution platform" drop-down menu and select "< New... >"

  2. In the "New Solution Platform" dialog, choose "x64" in the "Type or select the new platform" drop-down menu

  3. 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).

  4. Make sure (or setup) your "C/C++" -> "General" -> "Additional Include Directories" contains a path to your "SDL/include" folder

  5. Make sure (or setup) your "Linker" -> "General" -> "Additional Library Directories" contains a path to your "SDL/lib/x64" folder

  6. Make sure (or setup) your "Linker" -> "Input" -> "Additional Dependencies" contains "SDL2.lib;" and "SDL2main.lib;"

  7. 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

Related Questions