vscode-cmake-tools
vscode-cmake-tools copied to clipboard
vscode intellisense doesn't work with cmake
Hi, I just want to use CMake with vscode and link with Opencv library. After configure the CMakeList.txt, everything works fine. But when I am trying to add other head file and cpp file. The intellisense of vscode seems stop working.
It said #inlcude errors detected based on information provieded by the configuration provider settings.
What I set in settings is following the vscode instruction,
The project build and run successfully, so I think the problem is only for intellisense.
What I have tried else but didn't solve the error:
1.add include path to includePath and point compileCommands to compile_commands.json
Many thanks if can have some help.
- Operating System: <Ubuntu>
- CMake Version: <3.16.3>
- VSCode Version: <1.15.1>
- CMake Tools Extension Version: <1.5.3>
- Compiler/Toolchain: <GCC9.3.0>
Thank you for opening this issue, we will investigate. It would help if you can craft a standalone repro for us (or point us to some open source repository that you use). Our goal will be to make this work without c_cpp_properties.json or compile_commands.json.
@andreeis Thanks for you reply. I created the repo here. https://github.com/hahahouomg/test_for_cmakeVScode/tree/main Actually it is very simple, and I follow the instructions on opencv website to install opencv. https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html. Then follow this tutorial to set CMakelist.txt and cmake tool extension in vscode https://thecodinginterface.com/blog/opencv-cpp-vscode/ After that I found the intellisense is only work for main.cpp but not for testcpp.cpp and testheader.h file(sometimes work but later it shows error), and the project build and run successfully.
Having the same issue here, did anyone find a solution?
Having the same issue with Qt on MacOS. Did anyone find a solution?
Try to remove
"configurationProvider": "ms-vscode.cmake-tools"
, then compile_commands.json
works for me. I'm using it with conan.
.vscode/c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/local/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "${default}"
}
],
"version": 4
}
.vscode/settings.json
{
"C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
This also works in the case of glib-2.0
giving you headaches:
Try to remove
"configurationProvider": "ms-vscode.cmake-tools"