Hi i am using Visual c++ with SDL

I have been using a tutorial from lazy foo productions but when i go to build my solution my complier says:
Cannot open include file: 'SDL.h': No such file or directory

Dani AI

Generated

The compiler message means the header file is not being found on the compiler's include search path. was correct to point toward project include/link settings; the checklist below covers the less-obvious causes and fixes that still trip people up when using Visual C++ and SDL.

  • Confirm the header really exists and note its folder layout. SDL 1.2 headers are often under an SDL subfolder (e.g. include/SDL/SDL.h); SDL2 installers commonly use include/SDL2/SDL.h. Either add the parent folder to the compiler search path or change the include to match the layout.

  • Include-directive examples:

    #include <SDL.h>       // when the include dir points to the folder that directly contains SDL.h
    #include <SDL/SDL.h>   // when the header is inside an SDL subfolder (SDL 1.2)
    #include <SDL2/SDL.h>  // when headers are in an SDL2 subfolder
  • Make sure the include path change was applied for the active Configuration and Platform (Debug vs Release, Win32 vs x64). Settings made for one configuration do not automatically apply to others.

  • Watch for extraction-nesting and hidden extensions. Zipped SDKs often create an extra top-level folder, producing a wrong path. On Windows, confirm the file is SDL.h and not SDL.h.txt.

  • Match libraries and runtime to the SDL version and build target. Typical SDL2 link libraries are SDL2.lib and SDL2main.lib, and the SDL2.dll must be available at runtime. Use the libraries built for the same architecture as the project (x86 vs x64).

If the tutorial being followed targets a different SDL version, align the headers/libs to that version. These checks resolve the vast majority of "Cannot open include file" errors without changing code.

Recommended Answers

All 2 Replies

I know zero about SDL but do you have all of the directories set up properly?
The includes go under the Project/"YourProject"Properties/ConfigurationProperties/C-C++/AdditonalIncludeDirectories

You'll also need to put the libs directories under the Linker/AdditionalLibraryDirectories of that same Config Properties menu (and the names of the libs under the Linker/Input/AdditionalDependencies))

thanks i found this tutorial on youtube helped heaps.

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.