# Setting up SDL for Visual C++ 2005

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

## Recommended Posts

Gamedevers, Hey fellas, I am having a rough time making sure that im setting SDL up correctly for Visual C++ 2005 'Beta' edition. I copied the two *.lib files to my windows\system32 directory. I copied the two *.lib files to C:\Program Files\Microsoft Visual Studio 8\VC\lib I copied the header files to C:\Program Files\Microsoft Visual Studio 8\VC\include\SDL From what I Imagine is correct... I found that you need to actually let the software know about these two files, so I started a new project and looked around in the settings a bit. I found that if you go to the properties page, and down to Linker>>Input, you find "Additional Dependencies". Is that the correct place to put in sdl.lib and sdlmain.lib? When I attempt to do a quick compile of: #include <SDL/SDL.h> #include <iostream> using namespace std; int main() { return 0; } It gives me this error: Linking... LINK : fatal error LNK1104: cannot open file 'uuid.lib' Thanks for the help in advance.

##### Share on other sites
Copying static libraries into system32 folder is unnecessary, its DLLs that can go in there.

Anyways it appears you need the MS Platform SDK (required for win32 apps).

Once you've obtained that you must follow these instructions.

After which

create a project, then set-up the project settings for SDL:

C/C++ --> General --> Additional Include Directories = < insert sdl include directory >

Linker --> General --> Additional Library Directoires = < insert sdl library directory >

You can also setup SDL include/library directories to be always set like you do for the platform sdk given in the instructions at the link above.

##### Share on other sites
Your system32 directory isn't the place to put lib files I don't think, and I wouldn't really put 'em in visual studio's directory either. Personally, I have mine in the program files directory, like this:

"c:\Program Files\SDL\include\"
"c:\Program Files\SDL\lib"

Then in Visual Studio 2005, you need to go to the Tools>Options menu, and under Projects and Solutions>VC++ Directories, you add those two directories...

Set Include Files to "c:\Program Files\SDL\include\" and
set Library files to "c:\Program Files\SDL\lib".

If you actually meant that you're using Visual C++ 2005 Express Edition (Beta 2), then there's a bug where doing the above isn't possible...it doesn't offer a way to set the directory in the options. What you need to do instead is to edit a text file. Assuming you installed VC++ Express to Program Files, you need to edit this file:

"c:\Program Files\Microsoft Visual Studio 8\VC\vcpackages\VCProjectEngine.Dll.Express.Config"

and when you're done editing that file, you need to DELETE the file below or your changes won't work:

You may need to change "Administrator" in that path to whatever your login name is. Once you've edited the file and deleted that .dat file, you have to restart Visual C++.

Editing the VCProjectEngine.Dll.Express.Config file should be easy enough to figure out, but just in case...I'll show you a section of mine where I've added SDL, DirectX 9.0c, and the Platform SDK:

<Directories
Include="c:\Program Files\SDL\include;c:\Program Files\Microsoft DirectX 9.0c SDK (June 2005)\Include;c:\Program Files\Microsoft Platform SDK\Include;$(VCInstallDir)include;$(VCInstallDir)PlatformSDK\include;$(FrameworkSDKDir)include" Library="c:\Program Files\SDL\lib;c:\Program Files\Microsoft DirectX 9.0c SDK (June 2005)\Lib\x86;c:\Program Files\Microsoft Platform SDK\Lib;$(VCInstallDir)lib;$(VCInstallDir)PlatformSDK\lib;$(FrameworkSDKDir)lib;$(VSInstallDir);$(VSInstallDir)lib"
Path="c:\Program Files\Microsoft Platform SDK\Bin;$(VCInstallDir)bin;$(VCInstallDir)PlatformSDK\bin;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(FrameworkSDKDir)bin;$(FrameworkDir)$(FrameworkVersion);$(VSInstallDir);$(PATH)" Reference="$(FrameworkDir)$(FrameworkVersion)" Source="c:\Program Files\Microsoft Platform SDK\src\crt;$(VCInstallDir)crt\src"
/>

Once again, remember to delete VCComponents.dat when you're done editing!

As for the linker error that you got, I'd say its because either you haven't installed the Platform SDK, or you haven't set up the paths to the include and lib files for it. uuid.lib is from that Platform SDK. Check out this FAQ on how to install it for Visual C++ 2005 Express.

http://lab.msdn.microsoft.com/express/visualc/usingpsdk/default.aspx

There's a little bit more to getting SDL working, but this reply is already getting quite long, so I'll just quickly tell you. In your project's settings, you need to change the Runtime Library to Multi-threaded DLL which should be under C/C++>Code Generation. And if I remember right, for SDL, you can't just use "int main()", you need to add the parameters for the command line arguments, like this:

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

Then of course you need to add sdl.lib sdlmain.lib to the Additional Dependencies section of the Linker settings.

I actually made a project wizard to setup an SDL project automatically, 'cause it's quite a bit of work. Unfortunitly I have released it, but maybe I will someday. oh well...I'll bookmark this thread in case you need any other help. Good luck.

##### Share on other sites
One problem with some of the above methods: in VC 2005, you can't set additional include directories! Oh, and you don't need the Platform SDK to compile (at least I don't). Here's how I did it: copy the include/lib files to their proper directories in the installation, then in the project properties dialog, go to Configuration Properties->Input and add in sdlmain.lib and sdl.lib in the Additional Dependencies and add uuid.lib to the Ignore Specific Library field. Then, go to the C/C++ tree and select Code Generation, and change the Runtime Library to Multithreaded DLL.

That should work out for ya.

##### Share on other sites
Gamedevers,

I want to thank you all for your prompt response to this issue.

It's fixed, and I am now working through some tutorials from http://sol.planet-d.net/gp/index.html

This is what I didn't do (for future reference)
¤ Change Runtime Library to 'Multithreaded DLL'
¤ Ignore Specific Library -> 'uuid.lib'
¤ Placing SDL.DLL within the Visual Studio 8 Directory

Thanks for the help everybody!

##### Share on other sites
i can get it to work on Visual C++ 2005!

i keep on getting this error message:

------ Build started: Project: vtest, Configuration: Debug Win32 ------
LINK : fatal error LNK1561: entry point must be defined
Build log was saved at "file://c:\Documents and Settings\Alan\Desktop\vtest\vtest\Debug\BuildLog.htm"
vtest - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

##### Share on other sites
Check here: SDL:Tutorials:Setup

Regards.

##### Share on other sites
When I try to use SDL_opengl.h, it keeps saying that "cannot open windows.h". I assumed that the windows SDK would fix that, but it still doesn't work. What am I missing?

##### Share on other sites
Quote:
 Original post by n00bodyWhen I try to use SDL_opengl.h, it keeps saying that "cannot open windows.h". I assumed that the windows SDK would fix that, but it still doesn't work. What am I missing?

It sounds like you didn't install the SDK properly. Try making a blank project and including <windows.h>, and it should fail. The header search paths probably just need to be set up properly.

##### Share on other sites
"Compiling...
SDL_teste.cpp
LINK : fatal error LNK1561: entry point must be defined"

#include "SDL.h"   /* Todas as aplicações SDL precisam deste cabeçalho */#include <stdio.h>int main(void) {        printf("Initializing SDL.\n");        /* Inicializa padrões, Vídeo e Audio */    if((SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)==-1)) {         printf("Não foi possível inicializar SDL: %s.\n", SDL_GetError());        exit(-1);    }    printf("SDL inicializada.\n");    printf("Terminando SDL.\n");        /* Termina todos os subsistemas */    SDL_Quit();        printf("Terminando....\n");    exit(0);}

Anyone can help me??

Im with the libs linked, with uuid.lib ignored, with /MD and with no precompiled header.

Thanks!

##### Share on other sites
I found the problem....

I have to set the CONSOLE subsystem.

And then, use the main like this: "int main(int argc, char *argv[])"

"int main()" does not work.

;)

##### Share on other sites
I had a really difficult time with the SDL release and Visual Studio 2005 SP1.

I kept getting really annoying manifest errors when the debugger attempted to use/load the SDL.dll, and I spent too much time trying to track down these errors online.

The only workaround that immidiately fixed up these issues was to build the SDL source in VS2005.

hth,

##### Share on other sites
Quote:
 Original post by n00bodyWhen I try to use SDL_opengl.h, it keeps saying that "cannot open windows.h". I assumed that the windows SDK would fix that, but it still doesn't work. What am I missing?

I've got the same problem. I lloked into the VC/Includes directorie and it's just missing. No "windors.h" file. They aren't GL libraries too, so I think it could be related to the "Express" think (My guess is that in the free relase the just missed many libraries). Does anyone know how to fix it? I'm just trying to move from VC++ 6 to the 2005, but my projects don't work 'cause of that...

Thank you

##### Share on other sites
Before using SDL, make sure you have the latest version of Visual Studio with the latest service pack installed and the platform SDK installed and configured.

##### Share on other sites
Well...

first, thanks to lazy foo and his tutorials, which made me learn SDL.

Now that I can run my old project in VC++ 2005, SDL_image seems to have forgot how to load an jpg...

then loadedImage is just NULL u.u

(I'm getting off topic, no? should I open a new thread? xDDDD)

##### Share on other sites
Quote:
 Now that I can run my old project in VC++ 2005, SDL_image seems to have forgot how to load an jpg...loadedImage = IMG_Load( "Data/secsi.jpg" );then loadedImage is just NULL u.u

Try moving where the data folder is. The working directory may be different than where you are used to in VS 6.0. Your working directory is by default I think the same as where the source files are. That is where it is for me but I am not sure if I moved anything.

##### Share on other sites
Quote:
 Original post by AtridasWell... first, thanks to lazy foo and his tutorials, which made me learn SDL.Now that I can run my old project in VC++ 2005, SDL_image seems to have forgot how to load an jpg... loadedImage = IMG_Load( "Data/secsi.jpg" );then loadedImage is just NULL u.u(I'm getting off topic, no? should I open a new thread? xDDDD)

I realize this is an old thread, but I recently had the exact same issue, and found a solution. Chances are you are missing jpeg.dll on your system, which is included as part of the binary download of SDL_image from the SDL_image download page

You either need to include jpeg.dll in the same folder as your executable, or could put it somewhere "visible" to applications on your system, like in the windows\system32 folder.

Hope this helps anyone else that may be encountering the same issue. Sometimes SDL is a little too good at failing gracefully, and in this situation it simply doesn't load in the image...sadly it doesn't return an error code that I can see, or any way to tell that it happened because the jpeg.dll file wasn't found.