Strange SDL Setup Error

Started by
2 comments, last by mako_5 17 years, 1 month ago
I've used SDL with my MSVC++ version before for some small projects and didn't have any problems with it. EDIT: I'm using MSVC++ 7 However, I downloaded whatever update there was for SDL and made a new project and for some bizarre reason it doesn't link anymore. I only played around with SDL before, so I don't have any projects to run to check to see if its just that one project's settings. This is my build output:

------ Build started: Project: sdl_tests, Configuration: Debug Win32 ------

Compiling...
main.cpp
Linking...
sdlmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol _SDL_main referenced in function _main
Debug/sdl_tests.exe : fatal error LNK1120: 1 unresolved externals

Build log was saved at "file://c:\Documents and Settings\Paul\My Documents\projects\forge\sdl\sdl_tests\Debug\BuildLog.htm"
sdl_tests - 2 error(s), 0 warning(s)


---------------------- Done ----------------------

    Build: 0 succeeded, 1 failed, 0 skipped
Here's what I did: Added header files to C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\sdl Added library files to C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib Put the SDL.dll into C:\WINDOWS\system32 Set the C++ Code Generation to a multithreaded DLL Set the properties to include sdl.lib and sdlmain.lib as additional dependencies under "Linker Input" I did my best to follow the instructions as given on here. Also, I tried making the project multiple times (with different names) to make sure I didn't mess up the project settings. Could someone offer any suggestions, because I'm very confused as to what I did wrong or I'm missing? If you need anymore information to diagnose the problem, please let me know, because I've tried for an hour and I'm not sure why this isn't working. This is the source I'm trying to run:

#include <sdl/SDL.h>
int main() {
	SDL_Init(SDL_INIT_EVERYTHING);


	SDL_Quit();


	return 0;
}



Advertisement
I've had that problem many times before. I really should write down what I do to fix these things, because I can never remember. I'm pretty sure that it had something to do with the "Code Generation" setting though. Try all the different options and see if any of them let you compile.

I think it was "Multithreaded Debug DLL". I think that's how I got it to work. Sorry I couldn't give you a better answer, I just can't remember.
Quote:Original post by Uphoreum
I've had that problem many times before. I really should write down what I do to fix these things, because I can never remember. I'm pretty sure that it had something to do with the "Code Generation" setting though. Try all the different options and see if any of them let you compile.

I think it was "Multithreaded Debug DLL". I think that's how I got it to work. Sorry I couldn't give you a better answer, I just can't remember.


Thanks for your quick reply and looking at this problem. I just tried each of the different options for the Code Generation setting. Each produces additional errors, along with the one I was getting earlier.
Alright, I figured out the problem, so here's the solution if anyone is encountering the same thing.

Everything was setup correctly, except my program.

It appears that SDL does not like main functions that have no arguments. So in my source code, I changed:
int main()


to

int main(int argc, char* argv[])
, which fixed the problem.

This topic is closed to new replies.

Advertisement