Reputation: 47
I am using SDL in my project but I ran into a problem. I followed a tutorial on how to include SDL in MS visual studio herebut it did not help. Here are the steps that I took.
First, I added the SDL input directory in C/C++ / General "Additional input directories" block:
Second, I added the SDL lib directory in Linker / General "Additional library directories" block:
Third, I added SDL2.lib;SDL2main.lib to the "Additional dependencies" section under Linker / input:
And last, I set the subsystem section under Linker / system to Console (/SUBSYSTEM:CONSOLE):
This did not work, however, when I tried to run the test code that was supplied by the tutorial:
#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;
}
because I got these build errors when I debugged:
1>------ Build started: Project: Project2, Configuration: Debug Win32 ------
1>start.obj : error LNK2019: unresolved external symbol _SDL_GetError referenced in function _SDL_main
1>start.obj : error LNK2019: unresolved external symbol _SDL_Init referenced in function _SDL_main
1>start.obj : error LNK2019: unresolved external symbol _SDL_Quit referenced in function _SDL_main
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>c:\users\holger\documents\visual studio 2013\Projects\Game\Debug\Project2.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I thought that I followed the tutorial well, but apparently not. Please help me!
Thank you in advance!
Cheers engineers
Upvotes: 0
Views: 332
Reputation: 35454
The error seems to be that you're building a 32-bit application, but pointing to the 64-bit libraries.
Your error:
Build started: Project: Project2, Configuration: Debug Win32
But your library directory that you've set has x64
as the subdirectory.
Upvotes: 3