• Advertisement
Sign in to follow this  

SDL pisses me off

This topic is 1925 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, i am trying to use SDL but my IDE (VIsual c++ 2010) wont link SDL properly. I have tries making new projects, moving the folders, and re downloading it. Nothing worked. I am following Lazy Foos tutorials but im cannot get this stupid thing to work.

My code:

#include "SDL.h"
int main(){
SDL_Init(SDL_INIT_VIDEO);
SDL_Quit();
return 0;
}

My errors:

1>------ Build started: Project: SpaceShooter, Configuration: Debug Win32 ------
1> Main.cpp
1>Main.obj : error LNK2019: unresolved external symbol _SDL_Quit referenced in function "int __cdecl SDL_main(void)" (?SDL_main@@YAHXZ)
1>Main.obj : error LNK2019: unresolved external symbol _SDL_Init referenced in function "int __cdecl SDL_main(void)" (?SDL_main@@YAHXZ)
1>MSVCRT.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Users\Mathew\documents\visual studio 2010\Projects\SpaceShooter\Debug\SpaceShooter.exe : fatal error LNK1120: 3 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I hate this so much. I followed the tutorial to the letter, i re read it multiple times, and then googled it. I looked for a youtube tutorial Nothing worked. Please im desperate, i need help!

Share this post


Link to post
Share on other sites
Advertisement
The errors you posted are unrelated to your code. These are linker errors, not compiler errors.

Did you link to SDL?
How?


L. Spiro Edited by L. Spiro

Share this post


Link to post
Share on other sites
I followed the instructions on Lazy foo's website, http://lazyfoo.net/SDL_tutorials/lesson01/windows/msvsnet2010e/index.php. In the properties i added the path for the include and lib folder. then i changed the runtime library to Multi-Threaded dll. ANd then, under the linker section, i added SDL.lib and SDLmain.lib to the additional dependencies. I also changed the subsystem to Windows (/SUBSYSTEM:WINDOWS). I inputted the code he game me, then i got all those errors.

Share this post


Link to post
Share on other sites
What is the full path to SDLmain.lib? Copy-paste it.
What is the path you entered into your Library Directories? Copy-paste it.
What did you paste under Additional Dependencies? Copy-paste it.


L. Spiro

Share this post


Link to post
Share on other sites
There was no path t SDLmain.lib, i just put it in the additional Dependencies SDL.lib;SDLmain.lib;%(AdditionalDependencies):
Library directories: C:\SDL-1.2.15\lib\x64;$(LibraryPath)

Share this post


Link to post
Share on other sites
That doesn’t answer my question.
What is the path to SDLmain.lib? Open Explorer and browse to the file. Copy-paste its path.


L. Spiro

Share this post


Link to post
Share on other sites
Oh. Its in here C:\SDL-1.2.15\lib\x64, i had moved the Folders around from when i first posted this but i updated the project.

Share this post


Link to post
Share on other sites
You are compiling for a Win32 configuration, but the library you're linking to is x64 judging by your library folder. You should link against the Win32 (x86) version of the library

Share this post


Link to post
Share on other sites
I changed it, and it doesnt give me the errors but it says: The aplication was unable to start correctly(0xc000007b). Click OK to close the application.

Share this post


Link to post
Share on other sites
And this shows up in the output window:

'Space Shooter.exe': Loaded 'C:\Users\Mathew\Documents\Visual Studio 2010\Projects\Space Shooter\Debug\Space Shooter.exe', Symbols loaded.
'Space Shooter.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'Space Shooter.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Space Shooter.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
The program '[2036] Space Shooter.exe: Native' has exited with code -1073741701 (0xc000007b).

Share this post


Link to post
Share on other sites
Also try using
"int main(int argc, char *argv[])" instead of "int main()"... VC was giving me linking errors when using just main()

Share this post


Link to post
Share on other sites
Did you just copy (or move) the SDL lib from the x64 folder to the x86 one? That won't magically make it a 32-bit library. If you're building a 32-bit program you need a 32-bit library, and it doesn't matter what the folder it's in is called, if it's a 64-bit library it won't link.

Share this post


Link to post
Share on other sites
[quote name='n0name' timestamp='1349869948' post='4988682']
Also try using
"int main(int argc, char *argv[])" instead of "int main()"... VC was giving me linking errors when using just main()
[/quote]

@OP: I got the same error a few weeks ago and the quoted response solved the problem. You need the arguments to main for SDL to work correctly

Share this post


Link to post
Share on other sites
I tryed everything, i google the issue and people said that they had to reformate their drive and, and i did and now it works...YAY!

Share this post


Link to post
Share on other sites
[quote name='Mathew Bergen' timestamp='1349925170' post='4988944']
... people said that they had to reformate their drive and, and i did and now it works...
[/quote]
That sounds a little bit too extreme. You really should not have to do that. I am pretty sure you just had some libraries and files in the wrong places.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement