Need help to build a ceres project using eclipse-cdt on Ubuntu (Linker problem)

594 views
Skip to first unread message

Sonia

unread,
May 24, 2016, 11:46:14 AM5/24/16
to Ceres Solver
Hello, I tried to build helloworld from the ceres's example folder using eclipse-cdt on Ubuntu 14.04. Initially, I had loads of linker errors and to fix this I ended up adding lots of lib but still I couldn't build it successfully.

I have struggled solving this error and would appreciate any help on this. My ceres is 1.11.0.

hello_world.cpp:(.text._
ZN13MessageLoggerD2Ev[_ZN13MessageLoggerD5Ev]+0x12f): undefined reference to `google::log_sinks_global'

------
For the long detail, I started by building ceres-solver following http://ceres-solver.org/building.html#linux. I have installed all the packages:

sudo apt-get install libgoogle-glog-dev sudo apt-get install libatlas-base-dev sudo apt-get install libeigen3-dev

except libsuitesparse-dev as I already haved SuiteSparse 4.5.3 installed on my ubuntu. I built ceres succesfully.

Then I wanted to try to build my own project using ceres. I have started by create a C++ project using Eclipse and I used helloworld.cc as a source file, in my project I refered to it as hello_world.cpp. The compile and link command are below:

g++ -I/home/sonia/source/ceres-
solver-1.11.0/include -I/usr/include/eigen3 -I/home/sonia/source/ceres-solver-1.11.0/internal/ceres/miniglog -I/home/sonia/source/ceres-solver-1.11.0/config -O3 -Wall -c -fmessage-length=0 -std=c++11 -fpermissive -pthread  -DMAX_LOG_LEVEL -MMD -MP -MF"hello_world.d" -MT"hello_world.d" -o "hello_world.o" "../hello_world.cpp"

g++ -L/home/sonia/source/ceres-
bin/lib -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -L/home/sonia/source/SuiteSparse/lib -pthread -DMAX_LOG_LEVEL -o "hello_world"  ./hello_world.o   -lceres -lglog -lgtest -lgomp -lldl -ltest_util -lcolamd -lspqr -lumfpack -lmetis -lcholmod -lsuitesparseconfig -llapack -lamd -lcamd -lbtf -lklu -lblas

The compiling process was successful but the linker returned error about google::log_sinks_global which I have no idea about the link. So, I really appreciate your help on this.

Thank you very much.


Alex Stewart

unread,
May 24, 2016, 5:11:02 PM5/24/16
to ceres-...@googlegroups.com
Sonia,

I think the issue you are seeing is because of this:

-I/home/sonia/source/ceres-solver-1.11.0/internal/ceres/miniglog

which implies that you are trying to use Ceres as though it had MINIGLOG enabled.  However, you are also trying to link against actual glog, and the undefined reference error which strongly implies that Ceres was *not* compiled with MINIGLOG (on any recent version of Ceres, miniglog is actually compiled into Ceres itself if MINIGLOG is enabled).

In general on any platform where it is supported, we *strongly* recommend using glog over miniglog - it is much more powerful.

However, I would also recommend that you use CMake to build projects that depend on Ceres, we have an example for helloworld here:


it will make the handling of all Ceres dependencies automatic, which is *much* easier, and scales to different Ceres configurations (which have different dependencies).  This will also include adding, or not, the miniglog headers directory depending on whether Ceres was compiled with MINIGLOG.

Finally, as it looks like you are not installing Ceres, if you use the EXPORT_BUILD_DIR option:


then the Ceres build directory should be automatically detected by CMake when building the (separate) helloworld project (without any hints as to its location) - without Ceres having to be installed.

-Alex


--
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/6a18aa0f-41fd-4117-944c-3a1855725624%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sonia

unread,
May 26, 2016, 4:42:38 AM5/26/16
to Ceres Solver
Hi Alex,

Thanks very much for your help!

Your pointer about glog and miniglog saved my day. I was searching where to include "glog/logging.h" and found this under my ceres folder so I just included it without paying attention that's miniglog not glog that I installed. Finally, I could build the example project using Eclipse and got the results successfully.

Thanks,
Sonia
Reply all
Reply to author
Forward
0 new messages