# linking SDL in Visual C++ 2005

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

## Recommended Posts

Hello, I just download Visual C++ 2005 Express Edition Beta. I'm not sure how to setup the linker for SDL and OpenGL. Anyone have experiance with this product?

##### Share on other sites
In the older versions of visual studio (specifically VS.NET 2003) you would do this.

Click: Tools->OptionsSelect: Projects->VC++ DirectoriesAdd an entry for the SDL installation location (add for src, lib, header dirs etc..)Now after you create your project:Right click your project icon (after you open it in the right hand scrollable box) and select properties.Select the tab called "Librarian" or "Linker" and add an entry for your specific SDL dll file (usualy the dll name + ".lib") in the "Additional Dependancies" box.

Now you can include SDL specific headers and call on them without getting link errors.

g/l

##### Share on other sites
Now I'm getting:

main.obj : error LNK2005: _SDL_main already defined in game.obj
LINK : fatal error LNK1104: cannot open file 'uuid.lib'

##### Share on other sites
Quote:
 main.obj : error LNK2005: _SDL_main already defined in game.objLINK : fatal error LNK1104: cannot open file 'uuid.lib'

LINK : fatal error LNK1104: cannot open file 'uuid.lib'
This means your compiler cant find/open uuid.lib.

Already defined means you don't have your files correctly setup and its getting redefined or something. Most likely its defined in game.cpp or whatever object that points to.

##### Share on other sites
Guys, it's Beta. I had the same issues. I think SDL just doesn't work under VC8 yet. But in the future it'll be great. Like You can download custom templates and packs, like Dev-C++, but under the wide spread usability of VC. I only got VC7 becasue SDL_gfx had problems with Mingw and ahted it at first becasue I was hooked on DevPaks.

##### Share on other sites
1. Download SDL 1.2.8 and extract it to a location for it to stay in. (C:\Program Files\SDL 1.2.8).

2. Since VC++ is still beta, you are not able to set directories yet. Instead, you must include the header file from the complete path:
#include "C:\\Program Files\\SDL-1.2.8\\include\\SDL.h"
3. Now since you can't set directories and you need to add in library files, you must add those library files to the project. Right click on your project in the 'Solution Explorer' and choose "Add->Existing Item..." Now navigate to the /lib folder for SDL and add in the the SDL.lib and SDLMain.lib. Hit No on the new dialog, or if you hit Yes, then hit cancel.

4. Now go to "Project->Properties", "Linker->Input", and type in "uuid.lib" in the field that says "Ignore Specific Library".

5. Copy the SDL.DLL into your Debug/Release folders so it can be found when you run it. Everything should work fine now. Here's my code that I made for this test:
#include "C:\\Program Files\\SDL-1.2.8\\include\\SDL.h"Uint8 *g_Keys = 0;bool g_Done = 0;int g_Width = 640;int g_Height = 480;int g_BPP = 32;int g_Flags = SDL_DOUBLEBUF | SDL_HWSURFACE;SDL_Surface* g_Screen;SDL_Rect Dest;bool Initialize() {	Dest.x = 300;	Dest.y = 200;	Dest.w = 100;	Dest.h = 100;	return true;}void ProcessEvents( SDL_Event &event ){	if ( event.type == SDL_QUIT )		g_Done = 1;}void Update(){	g_Keys = SDL_GetKeyState( 0 );	if( g_Keys[ SDLK_ESCAPE ] )	{		g_Done = 1;	}}void Draw(){	SDL_FillRect( g_Screen, &Dest, 0x00FF00 );}void Deinitialize() {}int main(int argc, char *argv[]){	if ( SDL_Init(SDL_INIT_VIDEO) < 0 )	{		printf("Unable to init SDL: %s\n", SDL_GetError());		return -1;	}	atexit(SDL_Quit);	if( !Initialize() )	{		return -1;	}	if ( NULL == SDL_SetVideoMode( g_Width, g_Height, g_BPP, g_Flags ) )		return -1;	g_Screen = SDL_GetVideoSurface();	while( g_Done == false )	{		SDL_Event event;		while ( SDL_PollEvent(&event) )		{			ProcessEvents( event );		}		SDL_FillRect( g_Screen, NULL, 0x000000 );		Update();		Draw();		SDL_Flip( g_Screen );	}	Deinitialize();	SDL_Quit();	return 0;}

If anyone needs any help with what's been gone over feel free to ask [wink]. Good luck!

##### Share on other sites
how'd u figure out that uuid.lib thing, the rest seems obvious.

edit: nvrnmd, in errors. When I was trying, I tried to do it the same way they say to do the Platform SDK

##### Share on other sites
Visual C++ 2005 Beta 2 works just fine with setting directories up, its under Tools | Options...

and then the Projects and Solutions item on the left, VC++ Directories, as for linking you just need to goto project options, the linker, then input, and add SDL.lib and SDLmain.lib to the additional dependies box.

##### Share on other sites
Quote:
 Original post by neodingoVisual C++ 2005 Beta 2 works just fine with setting directories up, its under Tools | Options...

The OP and I are using the express ediitons [wink] I checked back here to post this quote for anyone else using the express edition on how to fix this:

Quote:
 Note: For Beta 2, you cannot set the Visual C++ Directories in the Options dialog of Visual C++ Express Edition. To work around this issue, you can update the Visual C++ Directories by modifying the VCProjectEngine.dll.express.config file located in the \vc\vcpackages subdirectory of the Visual C++ Express Edition install location. Please make sure that you also delete the file "vccomponents.dat" located in the "%USERPROFILE%\Local Settings\Application Data\Microsoft\VCExpress\8.0" if it exists before restarting Visual C++ Express Edition.

##### Share on other sites
Quote:
 Original post by YamianI tried to do it the same way they say to do the Platform SDK

I did that VCProjectEngine.dll.express.config with SDL and it didn't seem to work...

1. 1
2. 2
frob
16
3. 3
4. 4
5. 5
Rutin
10

• 19
• 13
• 14
• 76
• 22
• ### Forum Statistics

• Total Topics
632138
• Total Posts
3004359

×