Question

I am trying to compile a C++ program that uses OpenCV. My CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( main main.cpp )
target_link_libraries( main ${OpenCV_LIBS} )

However, when running make I get the following error:

make[2]: *** No rule to make target `/path/to/folder/opencv/lib/libopencv_contrib.so', needed by `main'.  Stop.

The reason is obvious: the .so files exist as .so.2.4.8 (where 2.4.8 is the OpenCV version) and not .so files, so make doesn't find them. How do I tell cmake to generate a makefile that uses the .so.2.4.8 files and not .so files?

No correct solution

OTHER TIPS

Normally, you link to an unversioned library that is a symbolic link to the versioned one.

In other words, you need a symlink (which is normally installed by the -devel package along with the header files):

.../libopencv_contrib.so -> .../libopencv_contrib.so.2.4.8

Another way is to link it as -l:libopencv_contrib.so.2.4.8 instead of -lopencv_contrib.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top