ubuntu下使用opencv问题以及解决方案

CMakeFiles/hw5_1_node.dir/computeORB.o: In function `cv::String::~String()':
/usr/local/include/opencv2/core/cvstd.hpp:664: undefined reference to `cv::String::deallocate()'
/usr/local/include/opencv2/core/cvstd.hpp:664: undefined reference to `cv::String::deallocate()'
CMakeFiles/hw5_1_node.dir/computeORB.o: In function `cv::String::operator=(cv::String const&)':
/usr/local/include/opencv2/core/cvstd.hpp:672: undefined reference to `cv::String::deallocate()'
CMakeFiles/hw5_1_node.dir/computeORB.o: In function `main':
/home/leonsun/backup/Homework/5/L5/Homework5_1/computeORB.cpp:50: undefined reference to `cv::imread(cv::String const&, int)'

都是因为没有在CMakeLists.txt中链接OpenCV库的原因,应该加入一下语句:

SET( CMAKE_CXX_FLAGS "-std=c++11 -O3")
PROJECT(hw5_1)
FIND_PACKAGE(OpenCV)
INCLUDE_DIRECTORIES(${OpenCV})
ADD_EXECUTABLE(hw5_1_node computeORB.cpp)
#TARGET_LINK_LIBRARIES(hw5_1_node ${OpenCV_LIBRARIES})

猜你喜欢

转载自www.cnblogs.com/leon-FFF/p/9229594.html