954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Setting up SDL on Visual C++ 2008 express edition

So I'm currently using Lazy Foo's tutorials. Here's the link:

http://lazyfoo.net/SDL_tutorials/lesson01/windows/msvsnet05e/index.php

I followed all the instructions, but I'm having a couple issues.

So when I choose an empty project, like the tutorials recommends, as opposed to one with a precompiled header, the C/C++ tab does not appear, and I am unable to manipulate all of the options. This is peculiarity number 1. I think it may have to do with the fact that the tutorial is designed for VC++ 2005, but I am using VC++ 2008.

Anyways, both when I choose an empty project and when I do not, I receive the same compiling error.

Here is my code.

// SDL.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "SDL/SDL.h" 

int main( int argc, char* args[] ) 
{ 
	//Start SDL 
	SDL_Init( SDL_INIT_EVERYTHING );

	//Quit SDL 
	SDL_Quit();

	return 0; 
}


Here is the error that I am getting.

1>------ Build started: Project: SDL, Configuration: Debug Win32 ------
1>Compiling...
1>SDL.cpp
1>c:\program files\microsoft visual studio 9.0\vc\include\sdl\sdl_stdinc.h(594) : fatal error C1083: Cannot open include file: 'close_code.h': No such file or directory
1>Build log was saved at "file://c:\Users\Nick\Documents\Visual Studio 2008\Projects\SDL\SDL\Debug\BuildLog.htm"
1>SDL - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Could this mean that I didn't link something properly or that I didn't copy and paste the SDL files into the Visual Studio lib folder properly? I'm not really sure.

Thank you for the help.

zoner7
Junior Poster
114 posts since Dec 2007
Reputation Points: 34
Solved Threads: 4
 

>>fatal error C1083: Cannot open include file: 'close_code.h': No such file or directory
It means exactuly what it says it means. The compiler can't find close_code.h ?

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

did you download the sdl source and compile it with your compiler?

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

If I remember correctly the Foo tutorials instruct you to get the pre-compiled binary DLLs.

It should have come with some header files. Did you put them in the include path? Did you tell VC++ where to find the lib files? Did you link with the SDL DLL?

Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
 

When I first setup SDL I had to go through the includes and remove start_code.h / end_code.h from the includes. Bah.

hacker9801
Junior Poster
130 posts since Aug 2007
Reputation Points: 59
Solved Threads: 16
 

hmm. I was able to remove and then redownload and reextract the begin_code.h / close_code.h headers. This solved my problem. Thanks for the help.

zoner7
Junior Poster
114 posts since Dec 2007
Reputation Points: 34
Solved Threads: 4
 

I know this thread is solved, but i've recently had alot of problems with SDL and visual 2008 c++ express. So heres some other things that may pop up, for the benefit of others looking at this post:

1.

#include "SDL/SDL.h"

This may be wrong. try setting it to plain old:

#include "SDL.h"

does that work?


2.

For any libraries you use, even the main lib or TTF, etc, include its corresponding DLL file (its in the includes file, in the SDL folder there arent many DLL's) in the debug folder of your project.

Does that work?


3.

This bit of code... in a very basic explanation, gets the compiler to check out the lib before using it in the program.

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

place this in whatever header file is at the top of your class hierarchy (probs stdafx.h) BEFORE your include statements

Does that work?

Any one of these or all of them combined I hope will solve most problems with setting up SDL....

Thats all i have at the mo... I wont go into how to include libs because there's loads of those already...

HOPE THIS HELPS!! IF IT DID, THEN PAY IT FORWARD AND SEE IF YOU CAN HELP SOMEONE ELSE!!

thriek
Newbie Poster
18 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You