- OpenCV => 4.5.5 (latest)
- Operating System / Platform => Ubuntu 20.04.4 LTS 64 bits on WSL2 for Windows 10 64 bits
- Compiler => g++ 11.1 (Ubuntu 11.1.0-1ubuntu1~20.04)
- Build System: CMake 3.23rc5, Unix Makefiles generator
Greetings, I have built OpenCV 4.5.5 from source with the sfm contrib module and I am trying to use it for scene reconstruction. However, whenever there is a call to cv::sfm::reconstruct
anywhere in the source code, I get the following linker error:
/usr/bin/ld: /usr/local/lib/x86_64-linux-gnu/libopencv_sfm.so.4.5.5: undefined reference to `cv::FlannBasedMatcher::add(cv::_InputArray const&)'
/usr/bin/ld: /usr/local/lib/x86_64-linux-gnu/libopencv_sfm.so.4.5.5: undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
/usr/bin/ld: /usr/local/lib/x86_64-linux-gnu/libopencv_sfm.so.4.5.5: undefined reference to `cv::DescriptorMatcher::knnMatch(cv::_InputArray const&, std::vector<std::vector<cv::DMatch, std::allocator<cv::DMatch> >, std::allocator<std::vector<cv::DMatch, std::allocator<cv::DMatch> > > >&, int, cv::_InputArray const&, bool)'
/usr/bin/ld: /usr/local/lib/x86_64-linux-gnu/libopencv_sfm.so.4.5.5: undefined reference to `libmv::MotionFromEssential(Eigen::Matrix<double, 3, 3, 0, 3, 3> const&, std::__debug::vector<Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::allocator<Eigen::Matrix<double, 3, 3, 0, 3, 3> > >*, std::__debug::vector<Eigen::Matrix<double, 3, 1, 0, 3, 1>, std::allocator<Eigen::Matrix<double, 3, 1, 0, 3, 1> > >*)'
/usr/bin/ld: /usr/local/lib/x86_64-linux-gnu/libopencv_sfm.so.4.5.5: undefined reference to `libmv::correspondence::nRobustViewMatching::computeCrossMatch(std::__debug::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)'
collect2: error: ld returned 1 exit status
All functions which failed to link are called from the SFM module.
I have checked that cv::FlannBasedMatcher::add
works outside the SFM module’s source files and it does, I get no linker error and the program builds successfully.
I have built and installed the following dependencies from source:
- Ceres-solver 1.2.1 [https:// github(dot)com/ceres-solver/ceres-solver/tree/2.1.0]
- Eigen 3.4 [https://gitlab.com/libeigen/eigen/-/tree/3.4]
- glog 0.5.0 [https:// github(dot)com/google/glog/tree/v0.5.0]
- gflags 2.2.2 [https:// github(dot)com/gflags/gflags/tree/v2.2.2]
- SuiteSparse 5.11.0-cmake.2 [https://github.com/sergiud/SuiteSparse/tree/5.11.0-cmake.2]
The following libs were installed through apt:
- BLAS & LAPACK (OpenBLAS implementation) [
libopenblas-dev/focal-updates,now 0.3.8+ds-1ubuntu0.20.04.1 amd64
]