I am using GLFW for a c++ project. I downloaded glfw3 using homebrew and have "/opt/homebrew/include" in the "includePath" field of the c++ configurations json file for vs code. Following the solution provided by this post (MacOS M1 -> fatal error: 'GLFW/glfw3.h' file not found), I also added the two paths to the .zshrc file, using terminal commands:
echo -n 'export CPATH=/opt/homebrew/include' >> ~/.zshrc (I also added export CPPPATH=...)
and
echo -n 'export LIBRARY_PATH=/opt/homebrew/lib' >> ~/.zshrc
, respectively. However, at compilation it still says that "GLFW/glfw3.h" is not found, even though the statement completion feature correctly identified both GLFW folder and glfw3.h file in the member lists. Thanks for your help!
c_cpp_properties.json
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks",
"/opt/homebrew/include",
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [],
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-arm"
}
],
"version": 4
}
tasks.json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "clang++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "C/C++: clang++ build active file"
}
]
}