Ceres dependency issue

2,604 views
Skip to first unread message

Narayanan Ramanathan

unread,
Apr 14, 2014, 1:56:06 PM4/14/14
to ceres-...@googlegroups.com
I am currently trying to use Bundler_SFM (https://github.com/snavely/bundler_sfm), a software for extracting structure from motion from videos. Bundler_SFM can optionally use Ceres for bundle adjustment. I built and tested Ceres as recommended in http://homes.cs.washington.edu/~sagarwal/ceres-solver/stable/building.html
At the 'make test' step, all 57 tests passed. 

But when I build bundler_sfm, I run into errors that read: 
/usr/local/lib/libceres.a(cxsparse.cc.o): In function `ceres::internal::CXSparse::SolveCholesky(cs_di_sparse*, cs_di_symbolic*, double*)':
cxsparse.cc:(.text+0x5a): undefined reference to `cs_di_free'
cxsparse.cc:(.text+0x67): undefined reference to `cs_di_malloc'
cxsparse.cc:(.text+0x7b): undefined reference to `cs_di_chol'
cxsparse.cc:(.text+0x95): undefined reference to `cs_di_ipvec'
cxsparse.cc:(.text+0xa1): undefined reference to `cs_di_lsolve'
cxsparse.cc:(.text+0xad): undefined reference to `cs_di_ltsolve'
cxsparse.cc:(.text+0xbf): undefined reference to `cs_di_pvec'
cxsparse.cc:(.text+0xc7): undefined reference to `cs_di_nfree'

Suitesparse did not run into build errors. What could be the issue ?

Thanks !

Sameer Agarwal

unread,
Apr 14, 2014, 1:57:28 PM4/14/14
to ceres-...@googlegroups.com
The undefined reference seems to indicate that you are not linking to CXSparse.

The linker needs to know where libcxsparse is.

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/b9fce425-3f47-420d-8093-074903f799ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Narayanan Ramanathan

unread,
Apr 14, 2014, 2:05:09 PM4/14/14
to ceres-...@googlegroups.com
I did an objdump on libcxsparse.a. The undefined references to cs_di_free, cs_di_malloc etc. exist in the same. Could the build errors below be as a result of build issues in Suitesparse ?

Sameer Agarwal

unread,
Apr 14, 2014, 2:06:11 PM4/14/14
to ceres-...@googlegroups.com
I mean that when you are building bundler you are missing a linker flag to libcxsparse.
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.

Alex Stewart

unread,
Apr 14, 2014, 2:07:46 PM4/14/14
to ceres-...@googlegroups.com
The issue is that bundler doesn't use CMake, so in src/Makefile at line 44, there is this:

CERES_LIBS= -lceres -lgomp -lglog -lcholmod -lpthread

Which hardcodes which libraries Ceres is using, several things:

1) This means Ceres must be installed to be found this way.

2) This assumes you're using GCC to compile, hence the -lgomp, Clang does not yet support OpenMP.

3) The full list of dependencies you should be adding here will be in: /usr/local/share/Ceres/CeresTargets-release.cmake (assuming you're on *nix), near the top after: "set_target_properties(ceres PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE …"

-Alex

Narayanan Ramanathan

unread,
Apr 15, 2014, 12:53:26 AM4/15/14
to ceres-...@googlegroups.com
With a recent patch to bundler_sfm (to src/Makefile), the compilation issues with Ceres turned ON went away and the bundler binaries were created. But upon invoking the bundler application, I ran into the following error, that seems to be pertaining to how Ceres was built. 
schur_complement_solver.cc is part of ceres-solver-1.8.0. How could I resolve this ?

Thanks

here is the error message, upon invoking bundler with Ceres turned ON. 
------------------------------------------------------------------------------
.......
[Ceres] Using CHOLMOD
   0: f: 5.598546e+01 d: 0.00e+00 g: 3.07e+03 h: 0.00e+00 rho: 0.00e+00 mu: 1.00e+04 li:  0 it: 3.14e-04 tt: 6.60e-04
WARNING: Logging before InitGoogleLogging() is written to STDERR
F0415 00:40:54.760443 61595 schur_complement_solver.cc:329] No SuiteSparse support in Ceres.
*** Check failure stack trace: ***
Aborted (core dumped)
------------------------------------------------------------------------------


On Monday, April 14, 2014 1:56:06 PM UTC-4, Narayanan Ramanathan wrote:

Sameer Agarwal

unread,
Apr 15, 2014, 1:03:30 AM4/15/14
to ceres-...@googlegroups.com
I do not think ceres was built with suitesparse support. 
before you try bundler, I recommend trying to run the bundle_adjuster example program that ships with ceres with linear_solver=sparse_schur.

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.

Narayanan Ramanathan

unread,
Apr 15, 2014, 1:30:55 AM4/15/14
to ceres-...@googlegroups.com
Thanks Sameer. Upon running the bundle_adjuster example program in ceres-solver-1.8.0, I get the underlying error message. I did not change the default configurations of Ceres. By default, Ceres is said to link SuiteSparse and its dependencies, when present. All the .lib files pertaining to SuiteSparse and its dependencies are contained at /usr/local/lib. How can I fix this issue with SuiteSparse support in Ceres ?

Thanks for your assistance.

Narayanan

--------------------------------------------------------
./bundle_adjuster --input=../../ceres-solver-1.8.0/data/problem-16-22106-pre.txt
   0: f: 4.185660e+06 d: 0.00e+00 g: 2.16e+07 h: 0.00e+00 rho: 0.00e+00 mu: 1.00e+04 li:  0 it: 1.44e-01 tt: 3.73e-01
F0415 01:19:37.540493 61727 schur_complement_solver.cc:329] No SuiteSparse support in Ceres.
*** Check failure stack trace: ***
    @     0x7f1eb678206d  google::LogMessage::Fail()
    @     0x7f1eb6783ef5  google::LogMessage::SendToLog()
    @     0x7f1eb6781c7b  google::LogMessage::Flush()
    @     0x7f1eb678482e  google::LogMessageFatal::~LogMessageFatal()
    @           0x4b67e1  ceres::internal::SparseSchurComplementSolver::SolveReducedLinearSystemUsingSuiteSparse()
    @           0x4b6a6d  ceres::internal::SparseSchurComplementSolver::SolveReducedLinearSystem()
    @           0x4b63b1  ceres::internal::SchurComplementSolver::SolveImpl()
    @           0x49ea73  ceres::internal::TypedLinearSolver<>::Solve()
    @           0x494f7e  ceres::internal::LevenbergMarquardtStrategy::ComputeStep()
    @           0x472eab  ceres::internal::TrustRegionMinimizer::Minimize()
    @           0x4662a7  ceres::internal::SolverImpl::TrustRegionMinimize()
    @           0x46a41d  ceres::internal::SolverImpl::TrustRegionSolve()
    @           0x46cb45  ceres::internal::SolverImpl::Solve()
    @           0x46265f  ceres::Solve()
    @           0x4431cf  ceres::examples::SolveProblem()
    @           0x43fefb  main
    @     0x7f1eb5786de5  (unknown)
    @           0x44074f  (unknown)
Aborted (core dumped)

Sameer Agarwal

unread,
Apr 15, 2014, 1:34:55 AM4/15/14
to ceres-...@googlegroups.com
have a look inside cmake/FindSuiteSparse.cmake for the requisite flags.

Sameer



Henrique Mendonça

unread,
Apr 15, 2014, 6:56:32 AM4/15/14
to ceres-solver
Hi Narayanan,

I didn't have any problems running bundler_sfm with ceres 1.8. What's your OS?
Perhaps you can use this as a reference if you're running it on Ubuntu or any Debian based system:
https://github.com/henrique/bundler_sfm/blob/master/.travis.yml

Best,
Henrique

Narayanan Ramanathan

unread,
Apr 15, 2014, 12:11:21 PM4/15/14
to ceres-...@googlegroups.com
Thank you for your input on how I can resolve this issue. 

I have narrowed down my problem to cmake being unable to find LAPACK and as a result Disabling SuiteSparse. I added the option -DLAPACK_LIBRARIES=<path for liblapack.a> to cmake. Then cmake could find LAPACK and enabled SuiteSparse. But in the make step, liblapack.a is said to have undefined references. The details are below. In attempts to fix LAPACK issues last week, I had installed Lapack 3.5.0 from source (from netlib.org), after have installed libatlas-base-dev. Should I uninstall that ? 

I guess I messed up the order in which these libraries need to be installed. 

I have installed the libraries as below:
sudo apt-get install -qq libatlas-base-dev libeigen3-dev gfortran libsuitesparse-dev
[Even tried a sudo apt-get --reinstall install <library>]

Output of : cmake ../ceres-solver-1.8.0
-------------------------------------------------------
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- A library with BLAS API found.
-- Looking for cheev_
-- Looking for cheev_ - not found
-- Did not find LAPACK library, disabling LAPACK support.
-- Found BLAS library: /usr/lib/libf77blas.so;/usr/lib/libatlas.so
-- Disabling SuiteSparse as use of LAPACK has been disabled, turn ON LAPACK to enable (optional) building with SuiteSparse.
-- Building without SuiteSparse.
-----------------------------------------------------------

Output of : make -j3

-----------------------------------------------------------
Linking CXX static library ../../lib/libtest_util.a
[ 64%] Built target test_util
Linking CXX executable ../bin/bundle_adjuster
/usr/bin/ld: /usr/local/atlas/lib/liblapack.a(ATL_dlarft.o): undefined reference to symbol 'cblas_ddot'
/usr/lib/libcblas.so.3: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [bin/bundle_adjuster] Error 1
make[1]: *** [examples/CMakeFiles/bundle_adjuster.dir/all] Error 2
make: *** [all] Error 2
-------------------------------------------------------------


--
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/h0nM0RPSgq4/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/CAPtH0jbqME4ECj7j7L4b4rqtj%2BjvpOZ0M96FYuEyJmYjLmZT6g%40mail.gmail.com.

Sameer Agarwal

unread,
Apr 15, 2014, 12:20:22 PM4/15/14
to ceres-...@googlegroups.com
you are mixing your lapack and libatlas.

atlas already provides lapack, so you should just use atlas.

Sameer



Reply all
Reply to author
Forward
0 new messages