Trying to get into SDL (Requirements for SDL based applications?)

Started by
29 comments, last by DavidGr 16 years, 8 months ago
I've heard plenty of good things about SDL (compatibility with OpenGL, easy to use, and most importantly cross platform), but the thing is I can't get it to work. I already had a project started and tried to add SDL and cannot for the life of me get past these linker errors. The project has the Multi-Threaded DLL setting The project is linked to SDL.lib and SDLmain.lib If the project includes either SDL.h or SDL_main.h, linker errors (see below) I use Visual C++ 2005 (version 8) First I tried including using the linker, that returned errors, so I changed it to just including within the source itself. If it's possible, I'd rather avoid this - I want cross platform portability. [script]#ifdef WIN32 #pragma comment(lib,"SDL.lib") #pragma comment(lib,"SDL_main") #endif #include <iostream> #include <cstring> #include <vector> #include <SDL_main.h> #include <SDL.h> using namespace std; int main(int argc,char*argv[]){ return(0); }[/script] This shouldn't have errors, but I keep getting the error: LINK : fatal error LNK1561: entry point must be defined When did main() stop being the entry point? How can I define main() as my entry point (or, since I've done some research, how do I get to that SDL_main() function? The macro obviously isn't working here)? I appreciate any answers and/or suggestions. [Edited by - Zouflain on August 6, 2007 2:33:03 AM]
Advertisement
Did you change the linker input settings in your project settings?
try to swap your pragmas :0)
I'm happy to be your BacKdoOrMaaan
Quote:Original post by Frizbe
Did you change the linker input settings in your project settings?

I tried this, but it did nothing. Besides, I thought the pragma's already covered that? Thank you anyway.
Quote:Original post by ForestMaster
try to swap your pragmas :0)

This, again, does nothing. Actually the reason they aren't in the same order as the header files is because I was experimenting with their placement. Thank you, though.
It's SDLmain not SDL_main.

Learn to make games with my SDL 2 Tutorials

Quote:Original post by Lazy Foo
It's SDLmain not SDL_main.

SDLmain.h? No such header file exists. I can see the library is called SDLmain, but not the header. If you did mean the library, please note that what I put was just a typo. The line should read:
Quote:#pragma comment(lib,"SDLmain.lib")

I was rather tired while typing that post.
are you using

int main(int argc, char* argv[])

as the parameters for the main method? if not try that :D
anyway why including SDL_main.h on your own? i thought SDL.h was already including it

#ifndef _SDL_H
#define _SDL_H

#include "SDL_main.h"
...

?
I'm happy to be your BacKdoOrMaaan
Quote:Original post by DavidGr
are you using

int main(int argc, char* argv[])

as the parameters for the main method? if not try that :D

Yes, I stated that in my original post. Thank you for offering a suggestion, though.
Quote:Original post by ForestMaster
anyway why including SDL_main.h on your own? i thought SDL.h was already including it

#ifndef _SDL_H
#define _SDL_H

#include "SDL_main.h"
...

?

I can't see how this makes a difference, and including or not including SDL_main.h does not change the compiler error, so it's unrelated.
Just follow these instructions exactly, and it should work.

Learn to make games with my SDL 2 Tutorials

This topic is closed to new replies.

Advertisement