I have a copy of OpenCV2.4.0 installed in / usr / local / lib
My program compiled properly, but when calling the linker, it generated errors such as:
/home/zhouw/moos-ivp-zhouw/trunk/src/pATRTest/mst.cpp:661: undefined reference to 'cv::_OutputArray::_OutputArray(cv::Mat const&)'
CMakeFiles/pATR.dir/mst.cpp.o:/home/zhouw/moos-ivp-zhouw/trunk/src/pATRTest/mst.cpp:675: more undefined references to `cv::_OutputArray::_OutputArray(cv::Mat const&)'
collect2: ld returned 1 exit status
make[2]: *** [../bin/pATR] Error 1
make[1]: *** [src/pATRTest/CMakeFiles/pATR.dir/all] Error 2
make: *** [all] Error 2
It is strange that my program uses opencv heavily, if CMake has problems finding libraries, he should have complained much more about undefined references than jsut.
I tried adding LINK_DIRECTORIES ("/ usr / local / lib") in my cmake file, but that didn't help. There, under / usr / local / lib, another library is installed called POCO. My program also links to POCO libraries, but CMake has no problem finding them.
If I manually contact -L / usr / local / lib, it will link correctly without errors.
CMakeLists.txt is as follows
PROJECT(pATR)
SET(SRCS
spline.hpp
utils.hpp utils.cpp
mst.hpp mst.cpp
cluster.hpp cluster.cpp
target.hpp target.cpp
detector.hpp detector.cpp
classifier.hpp classifier.cpp
atr.hpp atr.cpp
MOOSAtr.h MOOSAtr.cpp
main.cpp
)
ADD_EXECUTABLE(pATR ${SRCS})
TARGET_LINK_LIBRARIES(pATR opencv_core opencv_highgui opencv_imgproc MOOS)
INSTALL(TARGETS
pATR
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
)
, ? !