Upgrading CERES v1.14.0 to v2.0.0 - Error when linking CERES v2.0.0 in a C++ project
envgap__ceres-solver__ceres-solver-1063
Original GitHub issue ↗Opened 2024-04-05
01 / FAILURE SIGNATURE
As reported upstream
I'm trying to upgrade the version of CERES Solver in my project from `v1.14.0` to `v2.0.0` but I'm getting some errors during the compilation. With v1.14.0 it is compiling and working correctly but when I try to compile with v2.0.0 I got the next error:
Not a benchmark task.
- No curated issue-specific recipe or verified environment fix is available.
02 / ENVIRONMENT RECIPE
- Base commit
Not freshly verified- Manifest
CMakeLists.txt- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
ceres-solver/ceres-solver #1063 · read the original issue
**Development description:**
OS: Ubuntu `18.04`
Main project dependencies: OpenMVG `v1.2` and CERES `v2.0.0`
CMake version: `3.10.2`
Hi folks!
I'm trying to upgrade the version of CERES Solver in my project from `v1.14.0` to `v2.0.0` but I'm getting some errors during the compilation. With v1.14.0 it is compiling and working correctly but when I try to compile with v2.0.0 I got the next error:
```
Scanning dependencies of target test_transforms
[ 78%] Building CXX object tests/CMakeFiles/test_transforms.dir/test_transforms.cpp.o
[ 79%] Linking CXX executable test_transforms
../myproject/transforms/libmyproject_transforms.so: undefined reference to `ceres::Problem::AddResidualBlock(ceres::CostFunction*, ceres::LossFunction*, double* const*, int)'
collect2: error: ld returned 1 exit status
tests/CMakeFiles/test_transforms.dir/build.make:173: recipe for target 'tests/test_transforms' failed
make[2]: *** [tests/test_transforms] Error 1
CMakeFiles/Makefile2:2832: recipe for target 'tests/CMakeFiles/test_transforms.dir/all' failed
make[1]: *** [tests/CMakeFiles/test_transforms.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
```
It seems that it is a linking issue:
```
../libmyproject/transforms/libmyproject_transforms.so: undefined reference to `ceres::Problem::AddResidualBlock(ceres::CostFunction*, ceres::LossFunction*, double* const*, int)'
```
This is the way I'm defining the CMakeLists.txt for the module where I use CERES solver
```
cmake_minimum_required(VERSION 3.5)
project(myproject_transforms)
add_definitions(-std=c++14)
# Eigen used for SVD and others
find_package(Eigen REQUIRED)
include_directories(${EIGEN_INCLUDE_DIRS})
# OpenMVG for RANSAC related
add_definitions(${OPENMVG_DEFINITIONS})
# Ceres for bundle adjustment
find_package(Ceres REQUIRED)
target_link_libraries(${PROJECT_NAME} ceres)
include_directories(${CERES_INCLUDE_DIRS})
# Myproject common definitions and libraries
target_link_libraries(${PROJECT_NAME} ${MYPROJECT_THIRD_PARTY_LIBS})
add_definitions(${MYPROJECT_DEFINITIONS})
install(TARGETS ${PROJECT_NAME} DESTINATION lib EXPORT MYPROJECT_EXPORTS)
```
Can you give a hint about how to solve it?
Btw, I'm not sure if it is related but I disabled the `miniglog` included into OpenMVG repo because I was getting some issues during the compilation of my project. Instead I installed glog and gflags before compiling OpenMVG and CERES solver. One more note, the order I'm following for the compilation is:
1. gflags
2. glog
3. OpenMVG 1.2
4. CERES Solver 2.0.0
5. Myproject04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]
Issue-specific recipe and runtime smoke command require review against the complete issue and repository.
Legacy reproduction is generic install-only; match the actual issue failure before admission.