Closed sleeplessai closed 1 year ago
What does your compile_commands.json look like, and what is the actual include directory for opencv?
What does your compile_commands.json look like, and what is the actual include directory for opencv? This copy is generated by correct compiling cmake, I put it both in build/ and the project root.
[ { "directory": "/d/Devel/games101hw/Hw1/hw1/build", "command": "/clang64/bin/c++.exe -I/usr/local/include -isystem /clang64/include/opencv4 -std=gnu++17 -o CMakeFiles/Rasterizer.dir/main.cpp.o -c /d/Devel/games101hw/Hw1/hw1/main.cpp", "file": "/d/Devel/games101hw/Hw1/hw1/main.cpp" }, { "directory": "/d/Devel/games101hw/Hw1/hw1/build", "command": "/clang64/bin/c++.exe -I/usr/local/include -isystem /clang64/include/opencv4 -std=gnu++17 -o CMakeFiles/Rasterizer.dir/rasterizer.cpp.o -c /d/Devel/games101hw/Hw1/hw1/rasterizer.cpp", "file": "/d/Devel/games101hw/Hw1/hw1/rasterizer.cpp" }, { "directory": "/d/Devel/games101hw/Hw1/hw1/build", "command": "/clang64/bin/c++.exe -I/usr/local/include -isystem /clang64/include/opencv4 -std=gnu++17 -o CMakeFiles/Rasterizer.dir/Triangle.cpp.o -c /d/Devel/games101hw/Hw1/hw1/Triangle.cpp", "file": "/d/Devel/games101hw/Hw1/hw1/Triangle.cpp" } ]
You seem to have generated the compile_commands.json from a Cygwin or msys2 terminal. This creates Unix paths. Sublime text starts as a windows application and expects windows paths.
You seem to have generated the compile_commands.json from a Cygwin or msys2 terminal. This creates Unix paths. Sublime text starts as a windows application and expects windows paths.
Yes. But the eigen3 can index normally while opencv fails.
eigen3
isn't even in your compile_commands.json
? Maybe try to figure out why that is working, that could explain why opencv
isn't. Also make sure that those opencv
headers are present where they should.
eigen3
isn't even in yourcompile_commands.json
? Maybe try to figure out why that is working, that could explain whyopencv
isn't. Also make sure that thoseopencv
headers are present where they should.
Yes, it didn't contain eigen3 in json.
#include <eigen3/Eigen/Eigen>
#include <eigen3/Eigen/Dense>
#include <eigen3/Eigen/src/Core/Matrix.h>
#include <opencv2/opencv.hpp>
That's what I included in the source file. I can go to definition by eigen headers but opencv cannot find.
@rwols @LDAP
Good news here. This problem generally occurs on the current latest opencv4. The previous version seems alright.
Since the library headers at /clang64/include
can be indexed well, I guess the include/
has been indexed but the opencv4 has put itself at the wrong place.
What I did to solve this error is copying the whole /clang64/include/opencv4/opencv2
to upper directory /clang64/include/opencv2
. Now the extension senses opencv.hpp as expected.
I installed LSP and LSP-clangd as instructions both on my Windows and Linux workstations. The one on Linux works well but the other one fails to index because it cannot find opencv headers normally.
On Windows, I manage the environment with Msys2 includes Clang 15.0 compiler. I also installed the packages include the following two:
The eigen3 library and its headers are indexed correctly, LSP-clangd works well on it. I wrote the include syntax like
I generate a copy of compile_commands.json via CMake, but the error remains. I have no idea to solve the problem, please help me, thanks a lot.