Hi,
it took me a while to find my problem, so I'll report it here in case someone else runs into it.
The minimal example to reproduce my problem is compiling my exampleForBug.cpp in Debug mode (Release works fine):
#include "opencv2/opencv.hpp"
#include "opencv2/ximgproc.hpp"
int main()
{
cv::Mat currentBlock = cv::Mat::zeros(20,20,CV_16UC1);
cv::Mat filteredBlock;
cv::ximgproc::guidedFilter(currentBlock, currentBlock, filteredBlock, 42, 42.0);
}
using this CMakeLists.txt:
cmake_minimum_required(VERSION 3.1)
project( ExampleForBug )
set (CMAKE_CXX_STANDARD 11)
# use OpenCV
find_package( OpenCV REQUIRED HINTS "/path/to/debug/version/of/OpenCV")
include_directories ("${PROJECT_SOURCE_DIR}" "${OpenCV_INCLUDE_DIRS}" )
# set debug and release config as in makefiles which are provided
set(CMAKE_CXX_FLAGS_DEBUG "-g -D_DEBUG -D_GLIBCXX_DEBUG")
# state which binaries to build
add_executable( exampleProg "exampleForBug.cpp")
target_link_libraries(exampleProg "${OpenCV_LIBS}" )
This will reproduce linking errors. ./exampleForBug.cpp:8: error: undefined reference to `cv::ximgproc::guidedFilter(cv::debug_build_guard::_InputArray const&, cv::debug_build_guard::_InputArray const&, cv::debug_build_guard::_OutputArray const&, int, double, int)'
It can be fixed by removing -D_GLIBCXX_DEBUG from the cmake file. Apperently this an intentional fail in order to prevent linkage of binary incompatible DEBUG/RELEASE binaries/runtimes, see https://github.com/opencv/opencv/pull/9161
I'm fine with removing this option, I used it a while ago when looking for a bug and forgot to take it out again. However I think it should not be triggered by my setup. I use debug/release versions of OpenCV compiled on the same machine as the project where I'm using it (build with same version of compiler etc.). Thus there should be no problem with incompatible binaries.