Linking openCV library in CMake ubuntu
Hello, I am trying to link the octomap library with openCV library, but I have problem when I tried to generate the file using cmake. I confused about this problem, this is the error when I "make" my project file :
[ 47%] Linking CXX executable ../../../bin/simple_example
CMakeFiles/simple_example.dir/simple_example.cpp.o: In function `cv::Mat::~Mat()':
simple_example.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x15): undefined reference to `cv::Mat::deallocate()'
simple_example.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x71): undefined reference to `cv::fastFree(void*)'
collect2: error: ld returned 1 exit status
octomap/src/CMakeFiles/simple_example.dir/build.make:96: recipe for target '../bin/simple_example' failed
make[2]: *** [../bin/simple_example] Error 1
CMakeFiles/Makefile2:1450: recipe for target 'octomap/src/CMakeFiles/simple_example.dir/all' failed
make[1]: *** [octomap/src/CMakeFiles/simple_example.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
And this is my CMakeList.txt file :
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
PROJECT( octomap-distribution )
find_package( OpenCV REQUIRED )
set(OpenCV_DIR "/usr/local/include/opencv")
include_directories(${OpenCV_INCLUDE_DIRS})
ENABLE_TESTING() # enable CTest environment of subprojects
set(CMAKE_POSITION_INDEPENDENT_CODE ON) # enables -fPIC in applicable compilers (required to avoid link errors in some cases)
option(BUILD_OCTOVIS_SUBPROJECT "Build targets from subproject octovis" ON)
option(BUILD_DYNAMICETD3D_SUBPROJECT "Build targets from subproject dynamicEDT3D" ON)
option(OCTOVIS_QT5 "Link Octovis against Qt5?" NO)
if(OCTOVIS_QT5)
# Compiling against QT5 requires C++11.
set(CMAKE_CXX_STANDARD 11)
endif(OCTOVIS_QT5)
ADD_SUBDIRECTORY( octomap )
if(BUILD_OCTOVIS_SUBPROJECT)
ADD_SUBDIRECTORY( octovis )
endif()
if(BUILD_DYNAMICETD3D_SUBPROJECT)
ADD_SUBDIRECTORY( dynamicEDT3D )
endif()
I already try to link the openCV library into the cmakelist file but it totally failed, Is there anyone had experience solve this problem?? I am using opencv 3.3 and ubuntu 16.04
Thank you very much