Situation:
I have a Windows 7 machine with OpenCV for Windows installed on it. My OpenCV C++ projects work fine with Visual Studio 2010.
I want to run my existing OpenCV C++ projects to run on Raspberry Pi and on other Linux machines.
Trouble
As a first step, I am trying to compile my .cpp & .h files using GCC on Cygwin on my Windows Machine. For this purpose I am trying to use CMake package for Cygwin, but CMake gives error that it cannot find OpenCV package. (error is listed below).
Question:
- Do i need to install OpenCV package for Cygwin separately for CMake to work ?
- Is there a way to using my existing OpenCV for Win to work with CMake ?
- What environment variables need to be set ?
(Currently only a variable OPENCV_DIR is set to C:/opencv/build)
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.4)
PROJECT (testProj)
find_package(OpenCV REQUIRED )
set( NAME_SRC
src/main.cpp
src/imgProcess.cpp
)
set( NAME_HEADERS
include/imgProcess.h
)
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/include )
link_directories( ${CMAKE_BINARY_DIR}/bin)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
add_executable( testProj ${NAME_SRC} ${NAME_HEADERS} )
target_link_libraries( test ${OpenCV_LIBS} )
cmake error
$ cmake .
-- The C compiler identification is GNU 4.9.3
-- The CXX compiler identification is GNU 4.9.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++.exe
-- Check for working CXX compiler: /usr/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:3 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/cygdrive/c/Work/Project/cmaketest/CMakeFiles/CMakeOutput.log".
As @berak, stated in the comment, I installed OpenCV Package for Cygwin using Cygwin Ports. (Without any src or requiring any build, simple install only).
Had to tweak my
CMakeLists.txt
a little but it compiled well.(Now, I have totally different trouble of runtime error :
Gtk-WARNING **: cannot open display
, but its another story of not having XServer on Cygwin)The variable should be called
OpenCV_DIR
, it must have the same capitalization as infind_package(OpenCV REQUIRED)
.