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

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.

Dani AI

Generated

This is a compact troubleshooting addendum that ties together the helpful points in the thread and adds a few checks that frequently trip people using VC++ 2008 Express.

The actual error here (fatal C1083 for close_code.h) is literally "file not found" — as noted — and in this case the missing files (begin_code.h / close_code.h) came from an incomplete or mis-extracted SDL development package; re-extracting the dev archive fixed it for . Restoring those header files is the correct fix — do not patch the SDL headers out of existence (avoid the remove-include approach mentioned by ).

Checklist of precise things to verify (in the project that builds your .exe):

  • Confirm you unpacked the SDL "development" package and that the include tree contains the SDL folder with all headers (including begin_code.h and close_code.h).
  • Point the project at the right include folder: Project Properties -> Configuration Properties -> C/C++ -> General -> Additional Include Directories should include the parent that contains the "SDL" subfolder (not a nested, wrong-level path).
  • Point the linker at the SDL lib folder and add the SDL import libraries to your link input (the helper library for program startup plus the main SDL import library). Put the SDL runtime DLL(s) from the package into your program's output directory (Debug/Release) or on the PATH.
  • Ensure you are building Win32 and using the matching 32-bit SDL libs (VC++ 2008 Express commonly builds 32-bit binaries).

Two more gotchas to check: if your source still includes the auto-generated precompiled header (stdafx.h), either keep precompiled headers enabled or remove that include and set C/C++ -> Precompiled Headers to "Not Using Precompiled Headers." If the C/C++ property node is missing, make sure the project is a C++ application (not a Makefile project or wrong configuration).

Following the above usually resolves the C1083 close_code.h issue and avoids runtime problems. The suggestions from and about using the prebuilt SDL dev binaries and placing the DLL next to the exe are good practices to combine with these checks.

Recommended Answers

All 6 Replies

>>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 ?

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

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?

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

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.

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!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.