libtiff4 error with ROS - c++

I am trying to compile a ROS-package from a friend with catkin under Ubuntu 14.04 and am getting the following error:
/usr/bin/ld: warning: libboost_system.so.1.49.0, needed by
//usr/local/MATLAB/R2014a/bin/glnxa64/libut.so, may conflict with libboost_system.so.1.54.0
//usr/local/lib/libcvd.so: undefined reference to `TIFFWriteEncodedStrip#LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFReadRGBAImageOriented#LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFWriteScanline#LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFGetField#LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFClose#LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFClientOpen#LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFGetFieldDefaulted#LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFStripSize#LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFSetField#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libharfbuzz.so.0: undefined reference to `FT_Face_GetCharVariantIndex'
//usr/local/lib/libcvd.so: undefined reference to `TIFFSetErrorHandler#LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFReadScanline#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libharfbuzz.so.0: undefined reference to `FT_Get_Advance'
collect2: error: ld returned 1 exit status
I have libcvd installed and also libtiff4-dev. Has anybody any idea, how to solve that issue?
Thanks a lot,
snow
EDIT: As suggest I include the CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.3)
project(test)
set (test_VERSION "0.0.1")
find_package(OpenCV REQUIRED)
find_package(catkin REQUIRED COMPONENTS
test_core
cv_bridge
image_transport
roscpp
)
find_package(tracker)
set (CMAKE_CXX_FLAGS "-DNDEBUG -DNTIMING -DNRUN_UNIT_TESTS -g -O0 -std=c++11")
catkin_package(
INCLUDE_DIRS include
)
include_directories (include
${CMAKE_CURRENT_SOURCE_DIR}/include
${tracker_INCLUDE_DIRS}
${TRIANGULATION_INCLUDE_DIRS}
${OPENCV_INCLUDE_DIRS}
)
include_directories(/usr/local/MATLAB/R2014a/extern/include)
include_directories (SYSTEM
${catkin_INCLUDE_DIRS}
)
set (SOURCE
src/test/main.cc
src/test/rosbridge.cc
src/test/core.cc
)
add_executable (test ${SOURCE})
target_link_libraries(test
/lib/x86_64-linux-gnu/libssl.so.1.0.0
/lib/x86_64-linux-gnu/libcrypt.so.1
/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/usr/local/MATLAB/R2014a/bin/glnxa64/libmx.so
/usr/local/MATLAB/R2014a/bin/glnxa64/libeng.so
/usr/local/MATLAB/R2014a/bin/glnxa64/libmat.so
/usr/local/MATLAB/R2014a/bin/glnxa64/libut.so
${OpenCV_LIBS}
${tracker_LIBRARIES}
cvd
${catkin_LIBRARIES}
${TRIANGULATION_LIBRARIES}
)

Just linking cvd seems to not work in your case.
CMake comes with the great find_package feature, though, so let's use it:
Add find_package(CVD REQUIRED) at the top of the file
Add ${CVD_INCLUDE_DIRS} to include_directories
Replace cvd in target_link_libraries with ${CVD_LIBRARIES}
This may not work immediately but throw an error like "FindCVD.cmake not found". This is a script that searches your file system for the actual location of this library on your system and stores the paths to the variables used above. Many libraries already bring such an file themselves, but if this is not the case you have to provide it manually. In most cases you don't have to write this file yourself, though, as there is usually a bunch of open source projects, that already created such a file, which you can reuse (for example here). Just google "FindCVD.cmake" to find them.
Once you have this file:
Create a new subdirectory called "cmake" in your project and store the file there.
Add set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) at the top of your CMakeLists.txt (before the find_package call!)
Now it should hopefully work :)

I fixed it!
You have to link against the libtiff lib in your lib folder like this:
target_link_libraries(test
.
.
.
/usr/lib/x86_64-linux-gnu/libtiff.so.5
.
.
.
)

Related

libVLC|make: undefined reference to `libvlc_new'

For a small project, I decided to use libvlc hence C/C++.
Using different references I somehow installed opencv and libvlc libraries and also wrote the following CMake file:
cmake_minimum_required(VERSION 3.10)
project(untitled1)
set(CMAKE_CXX_STANDARD 14)
SET(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/cmake
${CMAKE_SOURCE_DIR}/config
${CMAKE_SOURCE_DIR}/config/platform
)
find_package(OpenCV REQUIRED)
find_package(LIBVLC REQUIRED)
file(GLOB SOURCE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
)
add_executable(untitled1 ${SOURCE_FILES})
# If the package has been found, several variables will
# be set, you can find the full list with descriptions
# in the OpenCVConfig.cmake file.
# Print some message showing some of them
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
if(CMAKE_VERSION VERSION_LESS "2.8.11")
# Add OpenCV headers location to your include paths
include_directories(${OpenCV_INCLUDE_DIRS})
endif()
include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${LIBVLC_INCLUDE_DIRS})
set(LIBS ${LIBS} ${OpenCV_LIBS})
set(LIBS ${LIBS} ${LIBVLC_LIBRARIES} )
target_link_libraries( untitled1 ${LIBS})
But when I do, cmake and then make I get the following error:
[100%] Linking CXX executable untitled1
CMakeFiles/untitled1.dir/VLCReader.cpp.o: In function `VLCReader::VLCReader(char*)':
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:17: undefined reference to `libvlc_new'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:18: undefined reference to `libvlc_media_player_new'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:21: undefined reference to `libvlc_video_set_callbacks'
CMakeFiles/untitled1.dir/VLCReader.cpp.o: In function `VLCReader::~VLCReader()':
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:26: undefined reference to `libvlc_media_player_stop'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:27: undefined reference to `libvlc_media_player_release'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:28: undefined reference to `libvlc_release'
CMakeFiles/untitled1.dir/VLCReader.cpp.o: In function `VLCReader::start(int, int)':
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:33: undefined reference to `libvlc_media_player_pause'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:34: undefined reference to `libvlc_media_new_location'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:35: undefined reference to `libvlc_media_player_set_media'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:36: undefined reference to `libvlc_media_release'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:38: undefined reference to `libvlc_video_set_format'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:39: undefined reference to `libvlc_media_player_play'
CMakeFiles/untitled1.dir/VLCReader.cpp.o: In function `VLCReader::pause(bool)':
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:45: undefined reference to `libvlc_media_player_set_pause'
CMakeFiles/untitled1.dir/VLCReader.cpp.o: In function `VLCReader::updataSize()':
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:51: undefined reference to `libvlc_video_get_width'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:52: undefined reference to `libvlc_video_get_height'
collect2: error: ld returned 1 exit status
CMakeFiles/untitled1.dir/build.make:166: recipe for target 'untitled1' failed
Please help me in going ahead. I am really new to C/C++ cmake based world.
Thanks #Tsyvarev and other people who pinted me in right direction.
My mistake in the CMake file is that I am using wrong variable names or say usng variables whihc are not defined.
LIBVLC_INCLUDE_DIRS to LIBVLC_INCLUDE_DIR
LIBVLC_LIBRARIES to LIBVLC_LIBRARY
Thanks all!

cmake c++ boost link

I know, there are plenty of different question out there regarding how to link boost libraries with a c++ project. However after hours of trying I still couldn't figure it out.
Here is my problem:
I need a filesystem library. Unluckily I didn't manage to use the new std::filesystem library so I thought let's simply use boost... until now I only needed some header only boost libraries, so I spend a couple of hours to finally manage to build boost (at least I think I have build it) in my directory C:/boost/stage/lib I have files called libboost_filesystem-mgw53-1_64.dll and so on...
I'm trying to use cmake to link these libraries to my own file, but I really get confused... First of all: in CMAKE should I use "BOOST" "Boost" or "boost"...
At the moment I have a mixture... I use something like:
set(CMAKE_CXX_STANDARD 17)
SET(BOOST_ROOT "C:/boost")
SET(BOOST_LIBRARYDIR "C:/boost/stage/lib")
find_package(BOOST 1.64.0 COMPONENTS system filesystem REQUIRED)
include_directories(${BOOST_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
set(SOURCE_FILES list of all my source files)
add_executable(myExecuteable ${SOURCE_FILES})
TARGET_LINK_LIBRARIES(myExecuteable ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
After hours I figured out that my find_package command only works if I type "BOOST" instead of "Boost"...
But I am not allowed to change:
SET(BOOST_ROOT "C:/boost")
to
SET(Boost_ROOT "C:/boost")
I'm using CLION and my Cmake now runs without error messages (finally...)
but if I try to build my program I get this error messages:
CMakeFiles\myFolder.dir/objects.a(main.cpp.obj): In function `_static_initialization_and_destruction_0':
C:/boost/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
C:/boost/boost/system/error_code.hpp:223: undefined reference to `boost::system::generic_category()'
C:/boost/boost/system/error_code.hpp:224: undefined reference to `boost::system::system_category()'
collect2.exe: error: ld returned 1 exit status
I have tried a lot of different solution provided here in previous questions but unluckily nothing worked so far...
I think I'm missing something obvious

How to link compiled cmph library in my project using CMake

In order to use cmph, a perfect minimal hashing library, in my project organised using CMake, I installed cmph library in a ubuntu machine and tested it using a single c file called main.c.
If I try to compile this file using gcc 5.3.0 using the following command:
gcc main.c
I will get the following output
/tmp/ccSOH5ob.o: In function `main':
testperfect.c:(.text+0x63): undefined reference to `cmph_io_vector_adapter'
testperfect.c:(.text+0x73): undefined reference to `cmph_config_new'
testperfect.c:(.text+0x88): undefined reference to `cmph_config_set_algo'
testperfect.c:(.text+0x9b): undefined reference to `cmph_config_set_mphf_fd'
testperfect.c:(.text+0xa7): undefined reference to `cmph_new'
testperfect.c:(.text+0xb7): undefined reference to `cmph_config_destroy'
testperfect.c:(.text+0xca): undefined reference to `cmph_dump'
testperfect.c:(.text+0xd6): undefined reference to `cmph_destroy'
testperfect.c:(.text+0xe2): undefined reference to `cmph_load'
testperfect.c:(.text+0x118): undefined reference to `cmph_search'
testperfect.c:(.text+0x153): undefined reference to `cmph_destroy'
testperfect.c:(.text+0x15f): undefined reference to `cmph_io_vector_adapter_destroy'
But if I run this command:
gcc main.c $(pkg-config --libs cmph) -o main
It will be compiled and run normally.
Now I need to add a similar piece of code in my project and the CMakeList.txt is written like this:
set(PROJECT_EXECUTABLE ${PROJECT_NAME})
# Compiling flags.
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
endif()
# Inject project config.
configure_file(
${PROJECT_INCLUDE_DIR}/phsim/config.hpp.in
${PROJECT_INCLUDE_DIR}/phsim/config.hpp
)
include(FindPkgConfig)
find_package(PkgConfig REQUIRED)
pkg_search_module(CMPH REQUIRED cmph)
target_link_libraries(Phsim ${CMPH_LIBRARIES})
target_include_directories(Phsim PUBLIC ${CMPH_INCLUDE_DIRS})
target_compile_options(Phsim PUBLIC ${CMPH_CFLAGS_OTHER})
# Compile executable.
file(GLOB SOURCES ${PROJECT_SRC_DIR}/*.cpp)
add_executable(${PROJECT_EXECUTABLE} ${SOURCES})
set_target_properties(${PROJECT_EXECUTABLE} PROPERTIES
VERSION ${PHSIM_VERSION_LITER}
)
And then I try to run cmake . and make, but only get the error message:
CMake Error at src/CMakeLists.txt:20 (target_link_libraries):
Cannot specify link libraries for target "Phsim" which is not built by this
project.
But I won't get target executable file unless I compile the project. If I try to compile my project without those commands related to library linking, the compiler will give similar link errors provided in the beginning of my question.
I have checked the following questions:
Undefined reference to cmph functions even after installing cpmh library
And I tried instructions provided by these sites:
https://cmake.org/Wiki/CMake:How_To_Find_Libraries
https://cmake.org/cmake/help/v3.6/module/FindPkgConfig.html
Many thanks in advance.
Finally Solved.
cmake_minimum_required(VERSION 3.0.2)
project(TestGamma)
set(GAMMATEST_VERSION_MAJOR 1)
set(GAMMATEST_VERSION_MINOR 0)
set(CMPH_INCLUDE_DIR /usr/local/lib)
include(FindPkgConfig)
configure_file(
"${PROJECT_SOURCE_DIR}/TestGammaConfig.h.in"
"${PROJECT_BINARY_DIR}/TestGammaConfig.h"
)
include_directories(${PROJECT_BINARY_DIR})
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(testgamma ${SOURCE_FILES})
pkg_check_modules(CMPH REQUIRED cmph)
include_directories(${CMPH_INDLUDE_DIR})
link_directories(${CMPH_INCLUDE_DIR})
target_link_libraries(testgamma cmph ${CMPH_INCLUDE_DIR})
Make sure to include pkgconfig at first and add link operations after calling "add_executable"
#usr1234567 Thank you for your attention.

Linking error in OpenGL using freeglut in CLion

So, I am using freeglut to try to do some openGL stuff, but I keep getting errors saying that references are undefined:
CMakeFiles\texture_mapping.dir/objects.a(TextureMapper.cpp.obj): In function `ZN13TextureMapper4initEv':
.../TextureMapper.cpp:20: undefined reference to `glClearColor#16'
.../TextureMapper.cpp:23: undefined reference to `glMatrixMode#4'
.../TextureMapper.cpp:24: undefined reference to `glLoadIdentity#0'
.../TextureMapper.cpp:25: undefined reference to `glOrtho#48'
CMakeFiles\texture_mapping.dir/objects.a(TextureMapper.cpp.obj): In function `ZN13TextureMapper7displayEv':
.../TextureMapper.cpp:45: undefined reference to `glClear#4'
...TextureMapper.cpp:48: undefined reference to `glColor3f#12'
...TextureMapper.cpp:49: undefined reference to `glBegin#4'
...TextureMapper.cpp:52: undefined reference to `glVertex3f#12'
...TextureMapper.cpp:53: undefined reference to `glVertex3f#12'
...TextureMapper.cpp:54: undefined reference to `glVertex3f#12'
...TextureMapper.cpp:55: undefined reference to `glVertex3f#12'
...TextureMapper.cpp:58: undefined reference to `glEnd#0'
...TextureMapper.cpp:61: undefined reference to `glFlush#0'
I am using MinGW with CLion to do this project. I thought that I got everything correctly. I moved the appropriate files into the include folder in MinGW, as well as the bin folder, and also the lib folder. Then, I have this in my CMakeLists.txt:
cmake_minimum_required(VERSION 3.3)
project(texture_mapping)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp TextureMapper.cpp TextureMapper.h Vertex.h ObjParser.cpp ObjParser.h)
add_executable(texture_mapping ${SOURCE_FILES})
target_link_libraries(texture_mapping libfreeglut.a libfreeglut_static.a)
The libraries I linked were the only library files that freeglut came with.
So, what am I missing? CLion doesn't show any errors before it is compiled. I can even go into the functions in the header files provided by freeglut. Why then, are these functions not defined in my program?
I have struggled with the same problem and solved it by appending following lines to CMakeLists.txt:
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES} ${GLUT_LIBRARY})
You did not actually link OpenGL to your project, so you get undefined references to OpenGL functions. Try to replace
target_link_libraries(texture_mapping libfreeglut.a libfreeglut_static.a)
with
target_link_libraries(texture_mapping libfreeglut.a libfreeglut_static.a GL)
I reproduced your issue with your CMakeLists.txt and the following program:
#include <GL/gl.h>
int main() {
glClear(GL_COLOR_BUFFER_BIT);
return 0;
}
and solved it with the above replacement. The solution automatically links GL library from my library path:
$ ls -1 /usr/lib64/libGL.*
/usr/lib64/libGL.la
/usr/lib64/libGL.so
/usr/lib64/libGL.so.1
/usr/lib64/libGL.so.1.0.0
UPDATE
According to this, you have some variables to access your actual OpenGL libraries. For example, you may point to OpenGL library file(s) directly like this:
target_link_libraries(texture_mapping libfreeglut.a libfreeglut_static.a ${OPENGL_gl_LIBRARY})
Also you may add OpenGL library directory to the library search path (do it before target_link_libraries):
link_directories(${OPENGL_gl_LIBRARY})
Reordering the CMakeLists.txt helped me (<name> should be replaced accordingly):
cmake_minimum_required(VERSION 3.10)
project(<name>)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lGL -lGLU -lglut")
set(CMAKE_CXX_STANDARD 17)
add_executable(<name> main.cpp)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES} ${GLUT_LIBRARY})

How to correct CMAKE error: package 'opencv' not found

OK, I know that opencv linking has been discussed before, but I can't see an error and I don't understand the corrective action. I'm trying to link DBoW2 library, which requires opencv. I'm getting undefined reference errors.
$ mingw32-make
Linking CXX shared library ..\lib\libDBoW2.dll
CMakeFiles\DBoW2.dir/objects.a(FORB.cpp.obj):FORB.cpp:(.text+0x124): undefined reference to `cv::Mat::zeros(int, int, int)'
CMakeFiles\DBoW2.dir/objects.a(FORB.cpp.obj):FORB.cpp:(.text+0x1db): undefined reference to `cv::fastFree(void*)'
CMakeFiles\DBoW2.dir/objects.a(FORB.cpp.obj):FORB.cpp:(.text+0x394): undefined reference to `cv::Mat::deallocate()'
CMakeFiles\DBoW2.dir/objects.a(FORB.cpp.obj):FORB.cpp:(.text+0x46a): undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
CMakeFiles\DBoW2.dir/objects.a(FORB.cpp.obj):FORB.cpp:(.text+0x503): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
CMakeFiles\DBoW2.dir/objects.a(FORB.cpp.obj):FORB.cpp:(.text+0x93f): undefined reference to `cv::Mat::create(int, int const*, int)'
collect2.exe: error: ld returned 1 exit status
Here's the CMakeLists.txt file
cmake_minimum_required(VERSION 2.8)
project(DBoW2)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native")
set(HDRS_DBOW2
DBoW2/BowVector.h
DBoW2/FORB.h
DBoW2/FClass.h
DBoW2/FeatureVector.h
DBoW2/ScoringObject.h
DBoW2/TemplatedVocabulary.h)
set(SRCS_DBOW2
DBoW2/BowVector.cpp
DBoW2/FORB.cpp
DBoW2/FeatureVector.cpp
DBoW2/ScoringObject.cpp)
set(HDRS_DUTILS
DUtils/Random.h
DUtils/Timestamp.h)
set(SRCS_DUTILS
DUtils/Random.cpp
DUtils/Timestamp.cpp)
find_package(OpenCV REQUIRED)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
include_directories(${OpenCV_INCLUDE_DIRS})
add_library(DBoW2 SHARED ${SRCS_DBOW2} ${SRCS_DUTILS})
target_link_libraries(DBoW2 ${OpenCV_LIBS})
I'm using the gui interface, and the parameter OpenCV_DIR automatically sets to C:/OpenCV/minwg_64. Under that directory there is a directory lib containing library files like "libopencv_videostab300.dll.a"
The CMakeCache.txt file contains the lines
//Dependencies for the target
DBoW2_LIB_DEPENDS:STATIC=general;opencv_videostab;general;opencv_videoio;general;opencv_video;general;opencv_superres;general;opencv_stitching;general;opencv_shape;general;opencv_photo;general;opencv_objdetect;general;opencv_ml;general;opencv_imgproc;general;opencv_imgcodecs;general;opencv_highgui;general;opencv_hal;general;opencv_flann;general;opencv_features2d;general;opencv_core;general;opencv_calib3d;
From what I've read, the following lines should be sufficient, but I'm getting the linker errors.
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(DBoW2 ${OpenCV_LIBS})
Edit 1:
In response to Chris Maes
added the pkg check
pkg_check_modules (OPENCV REQUIRED opencv)
Now the configure causes an error, which is progress, but I'm still at a loss. I must have an error in the opencv installation / build. I do have a second copy on an external drive, that was built recently (and easily) using something like cmake .. . But setting OpenCV_DIR to the external build produces the same error.
Found PkgConfig: C:/msys64/usr/bin/pkg-config.exe (found version "0.28")
checking for module 'opencv'
package 'opencv' not found
Edit 2:
Here are the settings that CMake automatically generates when I start a new cache and press generate twice (first time it only generates the make, sh).
CMAKE_BUILD_TYPE (BLANK)
CMAKE_GNUtoMS (UNCHECKED)
CMAKE_INSTALL_PREFIX C:/Program Files (x86)/DBoW2
CMAKE_MAKE_PROGRAM C:/msys64/mingw64/bin/mingw32-make.exe
CMAKE_SH C:/msys64/usr/bin/sh.exe
OpenCV_DIR C:/OpenCV/minwg_64
The directory C:/OpenCV/minwg_64 contains the opencv library built from mingw gcc 64, and cmake files including OpenCVConfig.cmake and directories bin and lib. I wonder if I need directory staticlib?
For windows environment, I have
OPENCV_DIR = C:\OpenCV\minwg_64 (where built bin and lib are located)
OPENCV_VER = 300
PATH includes C:\OpenCV\minwg_64\bin
On linux I use pkg_check_modules plugin for cmake:
find_package( OpenCV REQUIRED )
find_package( PkgConfig REQUIRED )
pkg_check_modules (OPENCV REQUIRED opencv)
include_directories(/usr/include/opencv2)
target_link_libraries(DBoW2 ${OPENCV_LDFLAGS})
note: I don't remember why I used hardcoded /usr/include/opencv2, but I guess OPENCV_INCLUDE_DIRS wasn't any good when I tried. There might be a more clean way :)