【发布时间】:2022-06-15 22:12:27
【问题描述】:
我正在尝试构建我的代码。
在我从构建目录执行cmake .. 之后,我执行make -j8 并得到
[ 90%] Building CXX object common/CMakeFiles/common.dir/src/utils/path_util.cpp.o
[ 95%] Linking CXX executable myproj
CMakeFiles/myproj.dir/main.cpp.o: In function `cv::String::~String()':
main.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'
CMakeFiles/myproj.dir/main.cpp.o: In function `cv::String::operator=(cv::String const&)':
main.cpp:(.text._ZN2cv6StringaSERKS0_[_ZN2cv6StringaSERKS0_]+0x28): undefined reference to `cv::String::deallocate()'
collect2: error: ld returned 1 exit status
CMakeFiles/myproj.dir/build.make:95: recipe for target 'myproj' failed
make[2]: *** [myproj] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/myproj.dir/all' failed
make[1]: *** [CMakeFiles/myproj.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
奇怪的是,我在代码中没有使用cv::String。
我也放了
#Search for dependencies
set(MIN_OPENCV_VERSION "3.4.11" CACHE STRING "OpenCV version")
find_package(OpenCV ${MIN_OPENCV_VERSION} REQUIRED
COMPONENTS core
PATHS /usr/local/opencv-${MIN_OPENCV_VERSION}
NO_DEFAULT_PATH
)
在几个CMakeLists.txt文件和cmake中找到opencv
可能是什么问题?
【问题讨论】:
-
你确定它甚至没有被间接使用。看起来你确实错过了
target_link_libraries。鉴于问题中的信息,我们既看不到有关您如何链接 OpenCV 的信息,也看不到有关您的main函数中可能发生的意外情况的任何信息。