Ask Your Question

Cmake can't find OpenCV

asked 2015-04-07 17:54:05 -0500

MalcolmMaya gravatar image

updated 2015-04-07 18:17:33 -0500

I was using OpenCv from the repo under Fedora 21. Since I wanted to use the latest version, I downloaded the git version and followed the install instruction here. However when I try to compile my old project which worked fine with the repo it doesn't seem to work anymore :

[malcolm@localhost build]$ make
Scanning dependencies of target mapmakerv3_automoc
[  7%] Automatic moc for target mapmakerv3
Generating MapMakerv3.moc
/mnt/bokkie/GoogleDrive/Work/AASS/TobotMaker/MapMakerGraphical/MapMakerv3/includes/Qtfiles/MapMakerv3.cpp:0: Note: No relevant classes found. No output generated.
Generating imageLabel.moc
/mnt/bokkie/GoogleDrive/Work/AASS/TobotMaker/MapMakerGraphical/MapMakerv3/includes/Qtfiles/imageLabel.cpp:105: Note: No relevant classes found. No output generated.
Generating moc_MapMakerv3.cpp
Generating moc_imageLabel.cpp
[  7%] Built target mapmakerv3_automoc
Scanning dependencies of target mapmakerv3
[ 14%] Building CXX object CMakeFiles/mapmakerv3.dir/includes/Qtfiles/MapMakerv3.cpp.o
In file included from /mnt/bokkie/GoogleDrive/Work/AASS/TobotMaker/MapMakerGraphical/MapMakerv3/includes/Qtfiles/MapMakerv3.h:18:0,
                 from /mnt/bokkie/GoogleDrive/Work/AASS/TobotMaker/MapMakerGraphical/MapMakerv3/includes/Qtfiles/MapMakerv3.cpp:1:
/mnt/bokkie/GoogleDrive/Work/AASS/TobotMaker/MapMakerGraphical/MapMakerv3/includes/Qtfiles/imageLabel.h:16:16: fatal error: cv.h: No such file or directory
 #include <cv.h>
compilation terminated.

Here is my CMakeList.txt :

cmake_minimum_required(VERSION 2.6)

set (MapMaker_VERSION_MAJOR 1)
set (MapMaker_VERSION_MINOR 0)

find_package(Qt4 REQUIRED)
find_package( OpenCV REQUIRED)

include_directories("${PROJECT_BINARY_DIR}" ${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} includes includes/Qtfiles includes/MapInterpretation/)

set(MapMakerv3_SRCS includes/Qtfiles/MapMakerv3.cpp main.cpp includes/Qtfiles/imageLabel.cpp)

add_executable(mapmakerv3 ${MapMakerv3_SRCS})
target_link_libraries(mapmakerv3 ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${OpenCV_LIBS})

add_executable(test_map_import Test/mapimport.cpp)
target_link_libraries(test_map_import ${OpenCV_LIBS} -lboost_unit_test_framework )

add_executable(test_voronoi Test/Voronoi_test.cpp)
target_link_libraries(test_voronoi ${OpenCV_LIBS} -lboost_unit_test_framework )

add_executable(test_delaunay Test/test_delaunay.cpp)
target_link_libraries(test_delaunay ${OpenCV_LIBS} -lboost_unit_test_framework )

install(TARGETS mapmakerv3 RUNTIME DESTINATION bin)


Appears I need to change all my include with "cv.h" to "opencv/cv.h". But it means my program will not work with someone who installed it from the repo. Why is that ?

[EDIT] even better if someone knows how I can make CMake use a version that I would install locally =) !

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-04-10 08:49:45 -0500

mshabunin gravatar image

updated 2015-04-10 08:50:28 -0500

Try to pass -DOpenCV_DIR=<folder-where-CMakeConfig.cmake-is-located> option to cmake when building your application.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-04-07 17:54:05 -0500

Seen: 1,846 times

Last updated: Apr 07 '15