Having trouble including header files


I can only use header files that I add to C:\SDL2-w64\include, but I Can’t get it to link to the include folder inside my project folder.

for example: I have a folder called "MyProject" and its located at C:\Users\User\Desktop\MyProject, inside the project folder there is an "Include" folder located at \MyProject\Include then I add a header file called "head.h" to the Include path. in my code I use #include <head.h>, I then get the error cannot open source file "head.h", but if I add head.h to C:\SDL2-w64\include it works perfectly fine.

anyone know how to include the Include folder located in my project folder?

my compiler settings are

    "configurations": [
            "name": "Win32",
            "includePath": [
            "defines": [
            "compilerPath": "C:\\msys64\\mingw64\\bin\\gcc.exe",
            "cStandard": "gnu17",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "windows-gcc-x64"
    "version": 4

>Solution :

Assuming the file doing the including is located at C:\Users\User\Desktop\MyProject, try using #include "Include/head.h". This is because there is a difference between using quotations ("") and angle brackets (<>) in your includes.

The reason is explained in this answer: https://stackoverflow.com/a/3162067/19099501

But to summarize it, with most compilers, #include "blah.h" will search in the local directory first, and then the stuff it can reach from what’s in your PATH variable, and #include <blah.h> will search from what’s in PATH only. I am guessing that C:\SDL2-w64\include is in your PATH. That is probably why when you moved the header file to that location, it was able to find it.

Leave a ReplyCancel reply