Reputation: 1276
I cloned, compiled and installed the master branch of OpenCV:
cmake .. -DCMAKE_INSTALL_PREFIX=/some/non-system-path \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_RPATH=/some/non-system-path
make
make install
Usual stuff, except that I'm installing it in a user path. To test it, I tried to run the following "hello world" example:
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char** argv )
{
if ( argc != 2 )
{
printf("usage: DisplayImage.out <Image_Path>\n");
return -1;
}
Mat image;
image = imread( argv[1], 1 );
if ( !image.data )
{
printf("No image data \n");
return -1;
}
namedWindow("Display Image", WINDOW_AUTOSIZE );
imshow("Display Image", image);
waitKey(0);
return 0;
}
with the following CMakeLists.txt
:
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( DisplayImage main.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
Note that this is exact example from OpenCV. It fails with the following:
[ 50%] Building CXX object CMakeFiles/DisplayImage.dir/main.cpp.o
make[2]: *** No rule to make target 'opencv_calib3d-NOTFOUND', needed by 'DisplayImage'. Stop.
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/DisplayImage.dir/all' failed
make[1]: *** [CMakeFiles/DisplayImage.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Looking in the /some/non-system-path/lib
there exists libopencv_calib3d.so
pointing to libopencv_calib3d.so.3.3.1
.
I assumed that this might be link_directories
issue, however, setting it didn't solve the problem either. As for ${OpenCV_LIBS}
I printed it and I got:
message(STATUS "OpenCV_LIBS = ${OpenCV_LIBS}")
-- OpenCV_LIBS = opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_shape;opencv_stitching;opencv_superres;opencv_video;opencv_videoio;opencv_videostab;opencv_viz
Any ideas?
Upvotes: 2
Views: 1922
Reputation: 347
I had this issue when was building OpenCV on Windows 10 with Visual Studio 2019 using CMake. x64-Debug
configuration was built successfully, but x64-Release
had opencv_calib3d-NOTFOUND
error.
A quote from alalek comment:
OpenCV supported builds are Debug and Release only. Other build configurations are not supported at all and proper compiler flags are not applied.
I noticed that CMakeSettings.json had RelWithDebInfo
configuration type for x64-Release
. So I changed it to Release
configuration type and that fixed the issue.
P. S. Also possible solution is described here, but I did not try it.
Upvotes: 1