[英]VSCode C++ IntelliSense/autocomplete is not working for OpenCV C++
OpenCV is installed from the source on my Linux (Ubuntu 18.04.6 LTS) machine. OpenCV 从源代码安装在我的 Linux(Ubuntu 18.04.6 LTS)机器上。 The path is a bit different ie
/usr/local/<blah_blah>
and the directory tree looks somewhat like this:路径有点不同,即
/usr/local/<blah_blah>
目录树看起来有点像这样:
milan@my_machine:/usr/local/<blah_blah>$ tree -L 4
.
├── bin
│ ├── opencv_annotation
│ └── ...
├── include
│ └── opencv4
│ └── opencv2
│ ├── ...
│ ├── core
│ ├── core.hpp
│ ├── ...
│ └── ...
├── lib
│ ├── cmake
│ │ └── opencv4
│ │ ├── OpenCVConfig.cmake
│ │ └── ...
│ ├── ...
│ ├── libopencv_core.so -> libopencv_core.so.4.2
│ ├── libopencv_core.so.4.2 -> libopencv_core.so.4.2.0
│ ├── libopencv_core.so.4.2.0
│ ├── ...
│ ├── ...
│ ├── opencv4
│ │ └── 3rdparty
│ │ ├── ...
│ │ └── ...
│ ├── python2.7
│ │ └── dist-packages
│ │ └── cv2
│ └── python3.6
│ └── dist-packages
│ └── cv2
└── share
├── licenses
│ └── opencv4
│ ├── ...
│ └── ...
└── opencv4
├── ...
│ └── ...
├── ...
└── ...
I had a similar issue for PCL (Point Cloud Library) in the past and my answer/solution fixed that.过去我对 PCL(点云库)有类似的问题,我的答案/解决方案解决了这个问题。 So, I tried something similar:
所以,我尝试了类似的东西:
In settings.json
, I put:在
settings.json
,我输入:
"C_Cpp.default.includePath": [
"/usr/local/<blah_blah>/include/opencv4/opencv2/**",
"/usr/local/<blah_blah>/include/opencv4/opencv2/core",
"/usr/local/<blah_blah>/include/opencv4/opencv2/core/*",
"/usr/local/<blah_blah>/include/opencv4/opencv2/core/**"
],
and in the c_cpp_properties.json
file, I put:在
c_cpp_properties.json
文件中,我输入:
"includePath": [
"${workspaceFolder}/**",
"${default}"
],
However, doing this is not fixing the issue.但是,这样做并不能解决问题。 C++ IntelliSense/autocomplete still does not work for OpenCV C++.
C++ IntelliSense/自动完成功能仍然不适用于 OpenCV C++。 So, how to fix this issue?
那么,如何解决这个问题呢?
Sample Code:示例代码:
Note1:注1:
cmake
, /usr/local/<blah_blah>/include/opencv4
is used under include_directories
.cmake
中, /usr/local/<blah_blah>/include/opencv4
在include_directories
下使用。 Note2: the following questions/issues are different from mine:注2:以下问题/问题与我的不同:
It turned out that in my settings.json
file, the includePath
s were set like this:原来,在我的
settings.json
文件中, includePath
是这样设置的:
"C_Cpp.default.includePath": [
"/usr/local/<blah_blah>/include/opencv4/opencv2/**",
"/usr/local/<blah_blah>/include/opencv4/opencv2/core.hpp",
"/usr/local/<blah_blah>/include/opencv4/opencv2/core",
.
.
],
However, in my code, the headers were included like:但是,在我的代码中,标题包括:
#include <opencv2/core.hpp>
If the opencv2
folder needs to be included in the #include
directive, the includePath
s should look like this:如果
opencv2
文件夹需要包含在#include
指令中,则includePath
应如下所示:
"C_Cpp.default.includePath": [
"/usr/local/<blah_blah>/include/opencv4",
.
.
],
So, the following includePath
s configuration fixed the issue with IntelliSense/autocompletion for OpenCV
:因此,以下
includePath
配置修复了OpenCV
的 IntelliSense/自动完成问题:
"C_Cpp.default.includePath": [
"/usr/local/<blah_blah>/include/opencv4",
"/usr/local/<blah_blah>/include/opencv4/**",
],
For a detailed explanation, take a look into the issue ( Issue 9900 ) I created on vscode-cpptools
GitHub page, particularly this thread/reply .有关详细说明,请查看我在
vscode-cpptools
GitHub 页面上创建的问题(问题 9900 ),尤其是此线程/回复。
Special thanks to vscode-cpptools
and vscode-cmake-tools
team!特别感谢
vscode-cpptools
和vscode-cmake-tools
团队!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.