C++ SDL.h file not found
See original GitHub issueGreetings,
I am using the Clangd extension on VS Code. VS Code reports the following error on my #include <SDL2/SDL.h>.
'SDL2/SDL.h' file not found clang(pp_file_not_found)
Running make results in no errors. Here is my Makefile:
CXXFLAGS = -Wall -Werror -std=c++11
SDL2FLAGS = -lSDL2
execs = chip8emu
all: chip8emu
chip8emu: chip8.cc chip8emu.cc
$(CXX) $(CXXFLAGS) $(SDL2FLAGS) -o $@ $^
clean:
rm -f $(execs)
I used bear, as per instructions on the clangd getting started page.
make clean; bear -- make
This results in the following compile_commands.json.
[
{
"arguments": [
"/usr/bin/c++",
"-c",
"-Wall",
"-Werror",
"-std=c++11",
"-o",
"chip8emu",
"chip8.cc"
],
"directory": "/Users/jasjeet/chip8",
"file": "/Users/jasjeet/chip8/chip8.cc",
"output": "/Users/jasjeet/chip8/chip8emu"
},
{
"arguments": [
"/usr/bin/c++",
"-c",
"-Wall",
"-Werror",
"-std=c++11",
"-o",
"chip8emu",
"chip8emu.cc"
],
"directory": "/Users/jasjeet/chip8",
"file": "/Users/jasjeet/chip8/chip8emu.cc",
"output": "/Users/jasjeet/chip8/chip8emu"
}
]
However, after restarting VS Code the error is still present. I have also tried adding “-I SDL2” to “arguments”.
System information Clangd extension version v0.1.11 Operating system: MacOS 11.5.2 SDL2 and bear were installed using Homebrew.
Thanks in advance.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
g++ compiler error: 'SDL.h' file not found · Issue #5167 - GitHub
From the build error, the command arguments for the g++ compiler needs to know the include path of "SDL.h". Can you try using...
Read more >SDL2 headers not being found when compiling os x
Does find /Library/Frameworks/SDL2.framework -name "SDL.h" find that header file? Is it under an SDL2 directory or somewhere else? – Drew MacInnis.
Read more >Setting up SDL 2 on Visual Studio 2019 Community
Cannot open include file: 'SDL.h': No such file or directory ... This means Visual C++ cannot find the SDL header files and you...
Read more >Cant find SDL.h - Windows, MingW, Cmake and SLD2 (in ...
I want to add SDL2 to a Cmake Project, using C++ in VSCode on Windows, but using Mingw64 from Msys2 (g++). This is...
Read more >SDL.h is not found? : r/cpp_questions - Reddit
Hi, I'm trying to make a game engine. I've created a little test that's building as a static library and another project that's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
echo | clang++ -E -v - | grep "/usr/local/include"
verified that the output includes that path:Adding
-I /usr/local/include/
toCXXFLAGS
in the Makefile, re-generatingcompile_commands.json
by runningmake clean; bear -- make
, and reloading the file in VS Code has cleared the errors. Thank you!I’m guessing the compiler has
/usr/local/include
in its default search path (but for some reason clangd does not?)You can verify this by running
echo | clang++ -E -v -
: does the output include/usr/local/include
?(As a workaround, adding
-I /usr/local/include/
to yourCXXFLAGS
and re-generating thecompile_commands.json
should fix the issue.)