Ceres Installation Issue google:: --> gflags::

1,349 views
Skip to first unread message

Manohar Kuse

unread,
Sep 15, 2021, 5:56:21 PM9/15/21
to Ceres Solver
Hi,
I have been trying to install ceres-1.14. As I try to do the make I get the following issue. 
I am aware this has to do with google:: namespace to gflags:: namespace. 
I have tried to look at the installation notes of ceres, however, it does not seem to help. 

Does anyone know to fix this issue and complete the installation? 

```
/home/manohar/Downloads/ceres-solver-1.14.0/internal/ceres/levenberg_marquardt_strategy_test.cc: In member function ‘virtual void ceres::internal::LevenbergMarquardtStrategy_CorrectDiagonalToLinearSolver_Test::TestBody()’:
/home/manohar/Downloads/ceres-solver-1.14.0/internal/ceres/levenberg_marquardt_strategy_test.cc:146:19: error: cannot declare variable ‘log’ to be of abstract type ‘testing::ScopedMockLog’
     ScopedMockLog log;
                   ^~~
In file included from /home/manohar/Downloads/ceres-solver-1.14.0/internal/ceres/levenberg_marquardt_strategy_test.cc:38:0:
/home/manohar/Downloads/ceres-solver-1.14.0/internal/ceres/gmock/mock-log.h:67:7: note:   because the following virtual functions are pure within ‘testing::ScopedMockLog’:
 class ScopedMockLog : public google::LogSink {
       ^~~~~~~~~~~~~
In file included from /home/manohar/Downloads/ceres-solver-1.14.0/internal/ceres/compressed_row_sparse_matrix.h:39:0,
                 from /home/manohar/Downloads/ceres-solver-1.14.0/internal/ceres/linear_solver.h:43,
                 from /home/manohar/Downloads/ceres-solver-1.14.0/internal/ceres/trust_region_strategy.h:36,
                 from /home/manohar/Downloads/ceres-solver-1.14.0/internal/ceres/levenberg_marquardt_strategy.h:35,
                 from /home/manohar/Downloads/ceres-solver-1.14.0/internal/ceres/levenberg_marquardt_strategy_test.cc:33:
/home/manohar/workspace_corvus/corvus_autonomy/devel/include/glog/logging.h:1426:16: note: virtual void google::LogSink::send(google::LogSeverity, const char*, const char*, int, const tm*, uint32_t, const char*, size_t)
   virtual void send(LogSeverity severity, const char* full_filename,
                ^~~~
internal/ceres/CMakeFiles/levenberg_marquardt_strategy_test.dir/build.make:75: recipe for target 'internal/ceres/CMakeFiles/levenberg_marquardt_strategy_test.dir/levenberg_marquardt_strategy_test.cc.o' failed
make[2]: *** [internal/ceres/CMakeFiles/levenberg_marquardt_strategy_test.dir/levenberg_marquardt_strategy_test.cc.o] Error 1
CMakeFiles/Makefile2:1581: recipe for target 'internal/ceres/CMakeFiles/levenberg_marquardt_strategy_test.dir/all' failed
make[1]: *** [internal/ceres/CMakeFiles/levenberg_marquardt_strategy_test.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 59%] Linking CXX executable ../../bin/compressed_col_sparse_matrix_utils_test
[ 59%] Linking CXX executable ../../bin/dynamic_compressed_row_sparse_matrix_test
[ 59%] Built target compressed_col_sparse_matrix_utils_test
[ 59%] Built target dynamic_compressed_row_sparse_matrix_test
[ 59%] Linking CXX executable ../../bin/autodiff_test
[ 59%] Built target autodiff_test
Makefile:145: recipe for target 'all' failed
make: *** [all] Error 2

```

Sameer Agarwal

unread,
Sep 15, 2021, 5:58:11 PM9/15/21
to ceres-...@googlegroups.com
1.14 is several years old. Please use ceres 2.0.0.
Sameer


--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/0d0e8bc3-11d4-4631-9a82-3a0e5a401d56n%40googlegroups.com.

Manohar Kuse

unread,
Sep 15, 2021, 6:10:52 PM9/15/21
to Ceres Solver
I `git checkout 2.0.0`. Cleaned the build and re-tried. 

I have the following versions of gflags and glog. 
```
libgflags-dev is already the newest version (2.2.1-1).
libgoogle-glog-dev is already the newest version (0.3.5-1).
```

Still seem to get a similar error message:
```
/home/manohar/Downloads/ceres-solver/internal/ceres/levenberg_marquardt_strategy_test.cc: In member function ‘virtual void ceres::internal::LevenbergMarquardtStrategy_CorrectDiagonalToLinearSolver_Test::TestBody()’:
/home/manohar/Downloads/ceres-solver/internal/ceres/levenberg_marquardt_strategy_test.cc:146:19: error: cannot declare variable ‘log’ to be of abstract type ‘testing::ScopedMockLog’
     ScopedMockLog log;
                   ^~~
In file included from /home/manohar/Downloads/ceres-solver/internal/ceres/levenberg_marquardt_strategy_test.cc:40:0:
/home/manohar/Downloads/ceres-solver/internal/ceres/gmock/mock-log.h:67:7: note:   because the following virtual functions are pure within ‘testing::ScopedMockLog’:
 class ScopedMockLog : public google::LogSink {
       ^~~~~~~~~~~~~
In file included from /home/manohar/Downloads/ceres-solver/internal/ceres/compressed_row_sparse_matrix.h:39:0,
                 from /home/manohar/Downloads/ceres-solver/internal/ceres/linear_solver.h:44,
                 from /home/manohar/Downloads/ceres-solver/internal/ceres/trust_region_strategy.h:37,
                 from /home/manohar/Downloads/ceres-solver/internal/ceres/levenberg_marquardt_strategy.h:36,
                 from /home/manohar/Downloads/ceres-solver/internal/ceres/levenberg_marquardt_strategy_test.cc:31:
/home/manohar/workspace_corvus/corvus_autonomy/devel/include/glog/logging.h:1426:16: note: virtual void google::LogSink::send(google::LogSeverity, const char*, const char*, int, const tm*, uint32_t, const char*, size_t)
   virtual void send(LogSeverity severity, const char* full_filename,
                ^~~~
internal/ceres/CMakeFiles/levenberg_marquardt_strategy_test.dir/build.make:75: recipe for target 'internal/ceres/CMakeFiles/levenberg_marquardt_strategy_test.dir/levenberg_marquardt_strategy_test.cc.o' failed
make[2]: *** [internal/ceres/CMakeFiles/levenberg_marquardt_strategy_test.dir/levenberg_marquardt_strategy_test.cc.o] Error 1
CMakeFiles/Makefile2:2404: recipe for target 'internal/ceres/CMakeFiles/levenberg_marquardt_strategy_test.dir/all' failed
make[1]: *** [internal/ceres/CMakeFiles/levenberg_marquardt_strategy_test.dir/all] Error 2

```


Sameer Agarwal

unread,
Sep 15, 2021, 6:12:30 PM9/15/21
to ceres-...@googlegroups.com
thats odd.
what platform is this on?
Sameer


Manohar Kuse

unread,
Sep 15, 2021, 6:14:15 PM9/15/21
to Ceres Solver
Ubuntu 18.04
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 


Sameer Agarwal

unread,
Sep 15, 2021, 6:26:26 PM9/15/21
to ceres-...@googlegroups.com
I suspect it has to do with the fact that glog version 0.3.5-1 is four plus years old.

The latest version is 0.5.0.


btw this issue only affects this test, you can just comment this test out if you want and continue.

Sameer


Manohar Kuse

unread,
Sep 15, 2021, 6:28:49 PM9/15/21
to ceres-...@googlegroups.com
I can try with version 0.5 for glogs. 

Meanwhile, how should I comment of this particular test that you are refering to? 


You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/MLx5AHMHnG0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUBoXOK6%3DCVT5DXmr_%3DriJ3Ygc7%3DVqjndXrCM_sCObf71Q%40mail.gmail.com.

Sameer Agarwal

unread,
Sep 15, 2021, 6:29:46 PM9/15/21
to ceres-...@googlegroups.com
just comment it out in the cmake file in internal/ceres/

Manohar Kuse

unread,
Sep 16, 2021, 1:01:37 PM9/16/21
to Ceres Solver
Hi Sameer,

Thanks yet again for your quick help, appreciated it! 

My issue is now solved and I was able to install ceres-2.0. Even `make test` resulted in full success. 
In file internal/ceres/CMakeLists.txt, line 466. I commented out the test `levenberg_marquardt_strategy`. 
Finally, I did the `make install`. 

I am trying to migrate some old ceres1.14 codes to ceres2. Here is a 'helloceres2.cc' that i have and
the corresponding cmakelists.txt file. I tried to follow: http://ceres-solver.org/installation.html#using-ceres-with-cmake 
However, I still seem to get a linker error. Do you know what is possibly wrong? 


```
CMakeFiles/helloceres2.dir/helloceres2.cc.o: In function `main':
helloceres2.cc:(.text.startup+0xb2): undefined reference to `ceres::Problem::AddResidualBlock(ceres::CostFunction*, ceres::LossFunction*, double*)'
collect2: error: ld returned 1 exit status
CMakeFiles/helloceres2.dir/build.make:122: recipe for target 'helloceres2' failed
make[2]: *** [helloceres2] Error 1
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/helloceres2.dir/all' failed
make[1]: *** [CMakeFiles/helloceres2.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
```


```helloceres2.cc
#include <ceres/ceres.h>

// using ceres::AutoDiffCostFunction;
// using ceres::CostFunction;
// using ceres::Problem;
// using ceres::Solve;
// using ceres::Solver;

class CostFunctor {
public:
template<typename T>
bool operator()( const T* const x, T* residual ) const {
residual[0] = 10.0 - x[0];
return true;
}
};

int main()
{
std::cout << "Hello Ceres 2\n";

double x;
const double initial_x = 0.5;
ceres::Problem problem;

ceres::CostFunction * cost_function =
new ceres::AutoDiffCostFunction< CostFunctor, 1,1 >( new CostFunctor ) ;
problem.AddResidualBlock( cost_function, nullptr, &x );

}
```


```cmakelists.txt
cmake_minimum_required (VERSION 3.5)
project (edge_align_standalone)

# Needs CERES, Eigen, OpenCV3
find_package(Eigen3 REQUIRED)
find_package(Ceres 2 REQUIRED)
find_package(OpenCV 4.5 REQUIRED )


include_directories(
# ${CERES_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
)

set( CMAKE_CXX_FLAGS "-fpermissive -std=c++14 -O3" )


add_executable(helloceres2 helloceres2.cc)
target_link_libraries(helloceres2 Ceres::ceres )
```

Alex Stewart

unread,
Sep 16, 2021, 1:49:23 PM9/16/21
to ceres-...@googlegroups.com
What is the result of 'make VERBOSE=1' ?  Is there an older version of Ceres installed in one of the paths used by the compiler or linker, do the paths that are present line up with the location where you installed Ceres 2.0 ?

I can't replicate this on an 18.04 test machine, and that is also what we use for Travis CI, so I think this is a specific issue with your local system.

-A

Manohar Kuse

unread,
Sep 16, 2021, 1:58:57 PM9/16/21
to Ceres Solver
I installed ceres2 in its default location (/usr/local??) 

```
manohar@vivobook:build (uptodating-2021 *%)$ make VERBOSE=1
/opt/cmake-3.21.1-linux-x86_64/bin/cmake -S/home/manohar/Downloads/edge_alignment/standalone -B/home/manohar/Downloads/edge_alignment/standalone/build --check-build-system CMakeFiles/Makefile.cmake 0
/opt/cmake-3.21.1-linux-x86_64/bin/cmake -E cmake_progress_start /home/manohar/Downloads/edge_alignment/standalone/build/CMakeFiles /home/manohar/Downloads/edge_alignment/standalone/build//CMakeFiles/progress.marks
make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/manohar/Downloads/edge_alignment/standalone/build'
make  -f CMakeFiles/helloceres2.dir/build.make CMakeFiles/helloceres2.dir/depend
make[2]: Entering directory '/home/manohar/Downloads/edge_alignment/standalone/build'
cd /home/manohar/Downloads/edge_alignment/standalone/build && /opt/cmake-3.21.1-linux-x86_64/bin/cmake -E cmake_depends "Unix Makefiles" /home/manohar/Downloads/edge_alignment/standalone /home/manohar/Downloads/edge_alignment/standalone /home/manohar/Downloads/edge_alignment/standalone/build /home/manohar/Downloads/edge_alignment/standalone/build /home/manohar/Downloads/edge_alignment/standalone/build/CMakeFiles/helloceres2.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/manohar/Downloads/edge_alignment/standalone/build'
make  -f CMakeFiles/helloceres2.dir/build.make CMakeFiles/helloceres2.dir/build
make[2]: Entering directory '/home/manohar/Downloads/edge_alignment/standalone/build'
[ 50%] Linking CXX executable helloceres2
/opt/cmake-3.21.1-linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/helloceres2.dir/link.txt --verbose=1
/usr/lib/ccache/c++ -fpermissive -std=c++14 -O3 CMakeFiles/helloceres2.dir/helloceres2.cc.o -o helloceres2  -Wl,-rpath,/home/manohar/workspace_corvus/corvus_autonomy/devel/lib /usr/local/lib/libceres.a /home/manohar/workspace_corvus/corvus_autonomy/devel/lib/libglog.so /home/manohar/workspace_corvus/corvus_autonomy/devel/lib/libgflags.so.2.2.1 -lpthread /home/manohar/workspace_corvus/corvus_autonomy/devel/lib/libspqr.a /usr/lib/x86_64-linux-gnu/libtbb.so /home/manohar/workspace_corvus/corvus_autonomy/devel/lib/libcholmod.a /home/manohar/workspace_corvus/corvus_autonomy/devel/lib/libccolamd.a /home/manohar/workspace_corvus/corvus_autonomy/devel/lib/libcamd.a /home/manohar/workspace_corvus/corvus_autonomy/devel/lib/libcolamd.a /home/manohar/workspace_corvus/corvus_autonomy/devel/lib/libamd.a /usr/lib/x86_64-linux-gnu/liblapack.so /usr/lib/x86_64-linux-gnu/libblas.so /usr/lib/x86_64-linux-gnu/libf77blas.so /usr/lib/x86_64-linux-gnu/libatlas.so /home/manohar/workspace_corvus/corvus_autonomy/devel/lib/libsuitesparseconfig.a /usr/lib/x86_64-linux-gnu/librt.so /home/manohar/workspace_corvus/corvus_autonomy/devel/lib/libmetis.so /home/manohar/workspace_corvus/corvus_autonomy/devel/lib/libcxsparse.a /usr/lib/x86_64-linux-gnu/liblapack.so /usr/lib/x86_64-linux-gnu/libblas.so /usr/lib/x86_64-linux-gnu/libf77blas.so /usr/lib/x86_64-linux-gnu/libatlas.so /home/manohar/workspace_corvus/corvus_autonomy/devel/lib/libsuitesparseconfig.a /usr/lib/x86_64-linux-gnu/librt.so /home/manohar/workspace_corvus/corvus_autonomy/devel/lib/libmetis.so /home/manohar/workspace_corvus/corvus_autonomy/devel/lib/libcxsparse.a 
CMakeFiles/helloceres2.dir/helloceres2.cc.o: In function `main':
helloceres2.cc:(.text.startup+0xb2): undefined reference to `ceres::Problem::AddResidualBlock(ceres::CostFunction*, ceres::LossFunction*, double*)'
collect2: error: ld returned 1 exit status
CMakeFiles/helloceres2.dir/build.make:122: recipe for target 'helloceres2' failed
make[2]: *** [helloceres2] Error 1
make[2]: Leaving directory '/home/manohar/Downloads/edge_alignment/standalone/build'
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/helloceres2.dir/all' failed
make[1]: *** [CMakeFiles/helloceres2.dir/all] Error 2
make[1]: Leaving directory '/home/manohar/Downloads/edge_alignment/standalone/build'
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2
```

Dmitriy Korchemkin

unread,
Sep 16, 2021, 3:37:25 PM9/16/21
to ceres-...@googlegroups.com
Hi,

Is it possible that you have a ceres-1.14 installation somewhere in default include paths?
Because `ceres::Problem::AddResidualBlock(ceres::CostFunction*, ceres::LossFunction*, double*)` is a signature from ceres-1.14 ( https://github.com/ceres-solver/ceres-solver/blob/1.14.x/include/ceres/problem.h#L230-L271 ), in new version it was replaced with variadic templates ( https://github.com/ceres-solver/ceres-solver/blob/master/include/ceres/problem.h#L239-L250 )

I suspect that you might have ceres-1.14 version somewhere in default include path (like /usr/include), and it comes before your custom installation in /usr/local/include.

But due to old version not having exported target in Ceres:: namespace, cmake tries to link new library to object files built with old headers.




--
Dmitriy A Korchemkin
Reply all
Reply to author
Forward
0 new messages