Sign in to follow this  

can i get a full walkthrough of how to setup SDL for VS express?

This topic is 4380 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

i need to set up SDL with VS2005 C++ Express edition, i've tried a couple times to set it up and each time it didn't work. can somebody walk me through it?

Share this post


Link to post
Share on other sites
best thing to do is to download Code::Blocks its got templates for sdl and everything.. its the perfect compiler... i have vc 2005 and i prefer codeblocks over it... if you go get that i can step you through that.

Share this post


Link to post
Share on other sites
What does "it didn't work" mean? Did you get a compiler error? If so, please post a few of them here. Were files you needed missing (like .h files)? Did it compile but nothing show up on the screen? Compile and then crash?



~BenDilts( void );

Share this post


Link to post
Share on other sites
when i try to compile it in VS i get

"fatal error LNK1561: entry point must be defined"
i have SDL.h in my header files

/* -- Include the precompiled libraries -- */
#include <iostream>
using namespace std;
#ifdef WIN32
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")
#endif

#include "SDL.h"

int main(int argc, char **argv)
{
//printf("\nHello SDL User!\n");

cout << "hi sdl user";

/* initialize SDL */
if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
fprintf( stderr, "Video initialization failed: %s\n",
SDL_GetError( ) );
SDL_Quit( );
}

SDL_Quit( );

return 0;
}

Share this post


Link to post
Share on other sites
everything is correct on there, i have the library and include files added to the VC++ Directories in the options menu. i have Multi-Threded DLL selected in Code Generation, sdl.lib and sdlmain.lib listed in the additional dependencies. i have the DLL in my project folder too.

Share this post


Link to post
Share on other sites
MSDN on your error. Basically, it means that the linker couldn't find your main() function. So maybe you created a Windows Forms project or a DLL project or LIB project by accident?



~BenDilts( void );

Share this post


Link to post
Share on other sites
i'm pretty sure, but just to be safe i tried again and made sure i selected empty project, same problem though.

Share this post


Link to post
Share on other sites
Try putting in
#define WIN32
at the top of your file. Perhaps, since you created an empty project, that preprocessor definition never got put in and thus you aren't linking with SDLmain.lib, causing your linking error.



~BenDilts( void );

Share this post


Link to post
Share on other sites
/* -- Include the precompiled libraries -- */
#define WIN32
#ifdef WIN32
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")
#endif

#include "SDL.h"

int main(int argc, char **argv)
{
printf("\nHello SDL User!\n");

/* initialize SDL */
if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
fprintf( stderr, "Video initialization failed: %s\n",
SDL_GetError( ) );
SDL_Quit( );
}

SDL_Quit( );

return 0;
}


same error :
i've checked the instructions over at least 5 times now, and made 3 new projects...

Share this post


Link to post
Share on other sites
._. i feel stupid...

i guess VS2005 just doesn't like SDL, because i went back and set it up again in VS2003, and it worked.

i compared everything for both VS2003 and VS2005, they both matched up perfectly, either that or there's some extra/different steps for setting it up with VS2005.

i may as well use VS2003 anyway, since i have it at home and at school, i only have VS2005 at home.

thanks for all the help everybody :D

not only do i have SDL set up now, but i'm pretty sure i can use the knowlege of how to setup SDL, and apply it to other things i might want to use.

Share this post


Link to post
Share on other sites
Quote:
Original post by econobeing
._. i feel stupid...

i guess VS2005 just doesn't like SDL, because i went back and set it up again in VS2003, and it worked.

i compared everything for both VS2003 and VS2005, they both matched up perfectly, either that or there's some extra/different steps for setting it up with VS2005.

i may as well use VS2003 anyway, since i have it at home and at school, i only have VS2005 at home.

thanks for all the help everybody :D

not only do i have SDL set up now, but i'm pretty sure i can use the knowlege of how to setup SDL, and apply it to other things i might want to use.


Shouldn't that be:

#pragma comment(lib, "SDLmain.lib")
#pragma comment(lib, "SDL.lib")

And not:

#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")


I personally prefer code::blocks but only because of it's simpleness. When it comes to debugging I ise microsoft since it is simply the best at that.

Share this post


Link to post
Share on other sites
I'm using VC2005 Express and can't duplicate your error - the code you posted compiles fine on my system. Weird.

I'm using the default project settings for an empty Win32 Console Application, not an empty project, though. That might be your problem - VC2005 is really nasty with its templates. But I still lub it :)

Share this post


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