c++ - 使用 Visual Studio Code 调试 C++,包括 Linux 中的 OpenCV
问题描述
我按照本教程在我的 Linux 中安装 OpenCV。
然后我按照另一个教程创建了 CMakeLists.txt。它看起来像这样:
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
然后我在终端中键入cmake CMakeLists.txt
以创建 Makefile 文件以最终执行make
以运行程序。
显然,我的程序包括opencv2/opencv.hpp。
当我尝试调试它时,问题就来了。我尝试包含所有库,但仍然有问题,因此无法调试。我的 tasks.json 如下:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-I${fileDirname}/build",
"-I${fileDirname}/opencv-master/include",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
然后我得到类似的错误:fatal error: opencv2/core.hpp: No such file or directory
,如果我尝试将所有这些 .hpp 包含在 tasks.json 中,我会得到类似的错误undefined reference to `cv::Mat::Mat()
,所以我不知道我该怎么做才能在 Visual Studio Code 中调试我的 c++ 文件。
我想我应该以某种方式将我的 Makefile 传递给 tasks.json,但我不知道我该怎么做。
谢谢。
解决方案
推荐阅读
- cordova - 在cordova-ionic 1中添加cordova admob插件后应用程序停止
- python-2.7 - Beam / DataFlow ::ReadFromPubSub(id_label) ::意外行为
- three.js - 三.js:文字精灵倒置显示
- vba - 重新计算父表单,而不会从子表单的当前记录中失去焦点
- java - Apache Camel Restlet - 无法提取多部分数据
- stata - 随机选择观察值
- node.js - 使用 Express 和 GraphQL 的 Windows 身份验证
- mysql - 如何使用 mysql 按产品 ID 对结果进行分组
- c - 如何将 *this 指针隐式传递给 struct 中的函数指针
- jenkins - 如何在变量中获取詹金斯构建状态?