提问人:ghulam2545 提问时间:5/29/2022 更新时间:5/29/2022 访问量:1093
未定义对“cv::Mat::Mat()”的引用?[关闭]
undefined reference to `cv::Mat::Mat()'? [closed]
问:
我正在尝试在cmake工具的帮助下设置opencv c++,这是我做过的事情,但是我遇到了一些错误,
我的CMakeLists.txt如下,
cmake_minimum_required(VERSION 3.0.0)
project(edge VERSION 0.1.0)
include(CTest)
enable_testing()
# these two line are added by me
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(edge main.cpp)
# this one line is added by me
target_link_libraries(edge ${OPENCV_LIBS})
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
这里是 PATH,PATH
我的vscode配置c_cpp_properties.json如下,
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${default}",
"C:\\opencv\\build\\include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "C:\\mingw64\\bin\\g++.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "${default}",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
我的 main.cpp 仅用于测试(我稍后会编写代码)。
#include <iostream>
#include <opencv2/opencv.hpp>
int main(int, char**) {
cv::Mat src;
std::cout << "Hello, world!\n";
return 0;
}
我的终端上有一些粗线,这里
[main] Building folder: edge edge
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build f:/edge/build --config Debug --target edge -j 4 --
[build] [ 50%] [32m[1mLinking CXX executable edge.exe[0m
[build] CMakeFiles\edge.dir/objects.a(main.cpp.obj): In function `main':
[build] F:/edge/main.cpp:5: undefined reference to `cv::Mat::Mat()'
[build] F:/edge/main.cpp:5: undefined reference to `cv::Mat::~Mat()'
[build] F:/edge/main.cpp:5: undefined reference to `cv::Mat::~Mat()'
[build] collect2.exe: error: ld returned 1 exit status
[build] mingw32-make.exe[3]: *** [CMakeFiles\edge.dir\build.make:99: edge.exe] Error 1
[build] mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:838: CMakeFiles/edge.dir/all] Error 2
[build] mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:845: CMakeFiles/edge.dir/rule] Error 2
[build] mingw32-make.exe: *** [Makefile:517: edge] Error 2
[build] Build finished with exit code 2
其实我想知道为什么会出现这些错误?如何修复。 (我猜是一些链接问题或其他问题。
注意 -:目前我在 Windows 环境中。(请考虑这一点)。
答: 暂无答案
评论
OpenCV_LIBS,CMake 区分大小写