I’m stumped trying to link the SDL libraries against a new C++ Win32 Console application in MVS 2010.
I downloaded the latest SDL development libraries, and did the usual steps:
- Added the includes to the include path (pic) [This works fine, as MVS finds the #include files]
- Added the library path for SDL (pic) [This seems to work fine, as removing this additional path gives the error “error LNK1104: cannot open file ‘SDL.lib'”]
- Added SDL.lib and SDLmain.lib to the linker additional dependencies (pic)
I edited the main file to have some test code, leaving it looking like this:
#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include "SDL.h"
int _tmain(int argc, _TCHAR* argv[])
{
int a;
SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO);
std::cout << "Pong" << std::endl;
std::cin >> a;
return 0;
}
And when I compile I get the following linker errors:
Error 1 error LNK2019: unresolved external symbol _SDL_Init referenced in function _wmain D:\All\Proyects\PFC\RT-Pong\RT-Pong\RT-Pong\RT-Pong.obj RT-Pong
Error 2 error LNK1120: 1 unresolved externals D:\All\Proyects\PFC\RT-Pong\RT-Pong\Debug\RT-Pong.exe 1 1 RT-Pong
In case I had a corrupted .lib, I downloaded the whole thing again, starting from 0, and got the same result. I’m honestly stumped, and it reeks of being a careless simple mistake that I’m overlooking. So if anyone has some fresh input on the matter, it would really make my day.
Thanks,
Jaime
I think you got linking error due to “wrong path defined at library path for SDL”
At
Project->Properties->Configuration Properties->Linker->General->Additional Library DirectoriesChange the path from this:
D:\All\Proyects\PFC\RT-Pong\SDL-1.2.15\lib\x64Into this:
D:\All\Proyects\PFC\RT-Pong\SDL-1.2.15\lib\x86