vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

vscode intellisense doesn't work with cmake

Open hahahouomg opened this issue 4 years ago • 7 comments

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.

Screenshot from 2020-11-25 12-03-29 It said #inlcude errors detected based on information provieded by the configuration provider settings.

What I set in settings is following the vscode instruction, Screenshot from 2020-11-25 12-09-00

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 Screenshot from 2020-11-25 12-13-29

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>

hahahouomg avatar Nov 25 '20 04:11 hahahouomg

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 avatar Nov 25 '20 18:11 andreeis

@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.

hahahouomg avatar Nov 26 '20 07:11 hahahouomg

Having the same issue here, did anyone find a solution?

igorgsouza avatar Jun 29 '22 01:06 igorgsouza

Having the same issue with Qt on MacOS. Did anyone find a solution?

HaoxuanGuo avatar Jul 09 '22 13:07 HaoxuanGuo

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"
}

solosuper avatar Jan 30 '23 19:01 solosuper

This also works in the case of glib-2.0 giving you headaches:

Try to remove

"configurationProvider": "ms-vscode.cmake-tools"

mletterle avatar Feb 14 '24 21:02 mletterle