techoe / ceres-solver

Automatically exported from code.google.com/p/ceres-solver
Other
0 stars 0 forks source link

Compilation fails with SuiteSparse -fPIC error on Ubuntu 12.04 #124

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Clone latest ceres-solver
2. Install gflags using self-created gflags deb package as described here: 
http://askubuntu.com/questions/312173/installing-gflags-12-04
3. Install glog using self-created glogs deb packages (had to edit dependencies 
to use libunwind7-dev instead of libunwind8-dev)
4. Create build directory, enter it, run "cmake .."

What is the expected output? What do you see instead?
Expect to succesfully compile, instead get:

[ 42%] [ 42%] Built target test_util
Built target gtest
[ 42%] Built target ceres
[ 42%] [ 42%] Built target array_utils_test
Built target autodiff_cost_function_test
Linking CXX shared library ../../lib/libceres_shared.so
[ 42%] Built target autodiff_local_parameterization_test
[ 42%] Built target autodiff_test
[ 42%] Built target blas_test
/usr/bin/ld: 
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libspqr.a(SuiteSparseQR_expert
.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when 
making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libspqr.a: could not read 
symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [lib/libceres_shared.so.1.7.0] Error 1
make[1]: *** [internal/ceres/CMakeFiles/ceres_shared.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 42%] [ 42%] Built target block_random_access_dense_matrix_test
Built target block_random_access_crs_matrix_test
make: *** [all] Error 2

What version of the product are you using? On what operating system?
* Latest ceres-solver from repo (fb465a0)
* gflags 2.0.1 for Quantal 
(https://launchpad.net/ubuntu/quantal/+source/gflagshttps://launchpad.net/ubuntu
/quantal/+source/gflags) manually repackaged for Precise.
* google-glog 0.3.2 for Quantal 
(https://launchpad.net/ubuntu/quantal/+source/google-glog) manually repackaged 
for Precise.

This is on a Ubuntu 12.04 LTS/AMD64 system.

Please provide any additional information below.

My main interest is getting ceres-solver installed on my 12.04 system. I'd be 
happy for any tips that allow working around this error.

Original issue reported on code.google.com by Stefan.K...@gmail.com on 13 Aug 2013 at 8:14

GoogleCodeExporter commented 9 years ago
Hi Stefan,
The problem here is not ceres, but a faulty suitesparse install on ubuntu.

There are two ways around it.

1. Build your own suitesparse with the proper shared library flags.
2. Turn off shared library building in ceres. You can do this via

cmake -DBUILD_SHARED=OFF

and the problem should go away.

Please let me know if this works for you.

Original comment by sameerag...@google.com on 13 Aug 2013 at 9:55

GoogleCodeExporter commented 9 years ago
Hi Sameer,

thanks for the quick answer! I tried option 1.) and after working around some 
undefined reference errors due to 'clock_gettime' in some suitesparse part 
(resolved by adding -lrt to the end of target_link_libraries for ceres), it now 
works fine.

regards,
Stefan

Original comment by Stefan.K...@gmail.com on 14 Aug 2013 at 8:08

GoogleCodeExporter commented 9 years ago
Happy to help.

Interesting about the target link libraries, I am not sure why we haven't faced 
that problem in the past. Perhaps on ubuntu the high precision timer support is 
not compiled into suitesparse by default?

I am closing this issue as wontfix for now. As there is nothing I can do about 
it at the level of ubuntu.

Original comment by sameerag...@google.com on 14 Aug 2013 at 2:01

GoogleCodeExporter commented 9 years ago
This has now been fixed in master at 54b43fefeacc785f46b40f3b022813922d9ae9f3 
with the caveat that a newer version of SuiteSparse than is shipped with Ubuntu 
(currently 3.4.0 as of 13.10) is still required.

I tested it with a source install of SuiteSparse v4.2.1 (default options) on 
Ubuntu 12.10 and everything works (irrespective of whether Ceres is compiled 
statically or dynamically).

Original comment by alexs....@gmail.com on 3 Oct 2013 at 8:21