I try using ROS with opencv, but when I 'catkin-make', it gives me this:
CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
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.
Call Stack (most recent call first):
fls_package/CMakeLists.txt:10 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/vered/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/vered/catkin_ws/build/CMakeFiles/CMakeError.log".
Makefile:318: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
with cmake-gui, I defined:
1. CMAKE_PREFIX_PATH = /home/vered/opencv/build (where OpenCVConfig.cmake is)
2. OpenCV_DIR = /usr/local/include/opencv4/opencv2 (where opencv.hpp is)
configured, generated and then sudo make install,
and still when catkin-make, i've got the same problem.
any ideas?
It seems that i tried all the solutions in the site, except this one:
ROS "catkin_make" cannot find OpenCVConfig.cmake
and that's what worked for me...
I just built opencv version 3.3.1 from source and I'm trying to link the libraries in a CMakeLists.txt file. In order to do that I need to know the install location.
It looks like I found it to be located at /usr/local/include. What is throwing me off is there are two "opencv" titled folders in this directory, one is name open "opencv" the other is named "opencv2". However there is no "opencv3" folder, but when I run $opencv_version in my terminal I get output "3.3.1-dev". So I know I've successfully installed opencv version 3, however I don't see a similarly named directory.
When looking at my make install output I see lines like:
Installing: /usr/local/include/opencv2/highgui/highgui.hpp
-- Installing: /usr/local/include/opencv2/highgui/highgui_c.h
-- Installing: /usr/local/lib/libopencv_superres.so.3.4.1
-- Up-to-date: /usr/local/lib/libopencv_superres.so.3.4
so it looks like I'm installing opencv version 3 with a directory named "opencv2". Did the engineers who made opencv version 3 really name their install directory opencv2???
I just would like confirmation to make sure I'm not crazy.
The short answer is yes.
I set the install directory for opencv in my make file as "/usr/local/include/opencv2" and the library was found. Also thanks to api55 for confirming my suspensions.
I am trying to install libqi for nao-ros and it gives me error: I already have gtest package but gtest_main is missing.
CMake Error at /home/shruti/d-prefix/share/cmake/qibuild/internal/uselib.cmake:80 (find_package): By not providing "FindGTEST_MAIN.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "GTEST_MAIN", but CMake did not find one.
Could not find a package configuration file provided by "GTEST_MAIN" with any of the following names:
GTEST_MAINConfig.cmake
gtest_main-config.cmake
Add the installation prefix of "GTEST_MAIN" to CMAKE_PREFIX_PATH or set "GTEST_MAIN_DIR" to a directory containing one of the above files. If "GTEST_MAIN" provides a separate development package or SDK, be sure it has been installed.
Any one knows about it?
I had the same problem when trying to build libqi and fixed it by:
cd /usr/share/cmake-3.0/Modules
ln -s FindGTest.cmake FindGTEST_MAIN.cmake
I am trying to build CI2CV on windows using cmake for the first time. I get below errors while building
"CMake Error at CMakeLists.txt:17 (find_package):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."
Tried to set CMAKE_PREFIX_PATH to location where OpenCVConfig.cmake file resides also tried the same with OpenCV_DIR. But no luck.
Please let me know way out of this.
You need to create a variable OpenCV_DIR and set that to the location where OpenCVConfig.cmake is:
cmake -DOpenCV_DIR:PATH=C:/opencv ..
Add to CMakeLists.txt:
set(OpenCV_DIR THE_PATH)
I'm trying to build project that has dependency to OpenCV. I installed Opencv using macports and when I try to build project, cmake gives the following output:
CMake Error at CMakeLists.txt:47 (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.
I searched a little bit about this problem and added the following env. variables to my $HOME/.profile file
export DYLD_LIBRARY_PATH=/opt/local/lib:$DYLD_LIBRARY_PATH
export CMAKE_PREFIX_PATH=/opt/local
without success. I checked and I have all opencv files istalled in /opt/local/lib and /opt/local/include/opencv directories. There is also OpenCVConfig.cmake in the following path:
/opt/local/lib/cmake/OpenCVConfig.cmake
How to make cmake know the path where opencv is installed? Previously I've build OpenCV on my own using cmake and installed into /usr/local and then it worked fine without any other fix. However I had some problems with ffmpeg and right now I switched to using macports.
Another option that works for me was set the env value OpenCV_DIR at the cmake opencv dir:
export OpenCV_DIR=/opt/local/lib/cmake/
macports traditionally installs OpenCV to /opt/local/ instead of the standard /usr/local/.
The solution to your problem is stated at:
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files.
When building your project in the command-line, make sure you execute:
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/local/lib/pkgconfig
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib
And then set the flag CMAKE_PREFIX_PATH for cmake:
cmake -D CMAKE_PREFIX_PATH=/opt/local ../
Not a MACPORT problem, but someone may find this helpful. Followed #hugh-pearse 's and #leszek-hanusz 's answers in this question, with a little tweak. I had installed opencv from ubuntu 12.10 repository (libopencv-)* and had the same problem. Couldn't solve it with export OpenCV_DIR=/usr/share/OpenCV/ (since my OpenCVConfig.cmake whas there). It was solved when I changed some lines on the OpenCVConfig.cmake file:
# ======================================================
# Include directories to add to the user project:
# ======================================================
# Provide the include directories to the caller
#SET(OpenCV_INCLUDE_DIRS "${OpenCV_INSTALL_PATH}/include/opencv;${OpenCV_INSTALL_PATH}/include")
SET(OpenCV_INCLUDE_DIRS "/usr/include/opencv;/usr/include/opencv2")
INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS})
# ======================================================
# Link directories to add to the user project:
# ======================================================
# Provide the libs directory anyway, it may be needed in some cases.
#SET(OpenCV_LIB_DIR "${OpenCV_INSTALL_PATH}/lib")
SET(OpenCV_LIB_DIR "/usr/lib")
LINK_DIRECTORIES(${OpenCV_LIB_DIR})
And that worked on my Ubuntu 12.10. Remember to add the target_link_libraries(yourprojectname ${OpenCV_LIBS}) in your CMakeLists.txt.
I finally read the header of the OpenCVConfig.cmake file.
It instructs to include these lines to use from an external project:
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(MY_TARGET_NAME ${OpenCV_LIBS})
(adding include_directories to CMakeLists.txt fixed it for me)
Make sure you have compiled OpenCV, once you compiled, OpenCVConfig.cmake will be generated in build directory.
follow these steps to compile
then , export OpenCV_DIR=<path to build directory with OpenCVConfig.cmake>
It should work now !
I tried all the above ideas in vain.
I eventually found a way to have the compilation work: Besides using #kengregson steps, I simply renamed the folder /usr/local/include/opencv2 so that it is not chosen when compiling my cpp file.
Since I compile my own OpenCV in a multiple-users server, so I can't install the OpenCV libs in /usr/local directly, but in my home folder instead, then exactly the same issue occurs to me.
Below is how I fix it:
Flowing the steps in OpenCV official doc: Using OpenCV with gcc and CMake
Add displayImage test program, and use this CMake file
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV)
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
The same error happened, so add one environment variable in my .tcshrc
setenv OpenCV_DIR "${folder where contains OpenCVConfig.cmake }"
\# mine is:
setenv OpenCV_DIR "~/local/OpenCV2.4.13/share/OpenCV"