techoe / ceres-solver

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

DSO missing symbols from command line - choldmod #153

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When building with suitesparse on ubuntu 14.04:

cmake -DCXSPARSE_INCLUDE_DIR=/usr/include/suitesparse -DBUILD_SHARED_LIBS=ON ..

I'm getting a linking error:

cd /home/snorri/tmp/ceres-solver/build/internal/ceres && /usr/bin/cmake -E 
cmake_link_script 
CMakeFiles/compressed_col_sparse_matrix_utils_test.dir/link.txt --verbose=1
/usr/bin/c++    -fopenmp -Werror=all -Werror=extra -Wno-unknown-pragmas 
-Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -O3 
-DNDEBUG     
CMakeFiles/compressed_col_sparse_matrix_utils_test.dir/compressed_col_sparse_mat
rix_utils_test.cc.o  -o ../../bin/compressed_col_sparse_matrix_utils_test 
-rdynamic ../../lib/libtest_util.so ../../lib/libceres.so.1.10.0 
../../lib/libgtest.so -lgflags -lglog 
-Wl,-rpath,/home/snorri/tmp/ceres-solver/build/lib 
/usr/bin/ld: 
CMakeFiles/compressed_col_sparse_matrix_utils_test.dir/compressed_col_sparse_mat
rix_utils_test.cc.o: undefined reference to symbol 'cholmod_free_sparse'
//usr/lib/x86_64-linux-gnu/libcholmod.so.2.1.2: error adding symbols: DSO 
missing from command line
collect2: error: ld returned 1 exit status

Looks like it needs to directly link against the suitesparse libraries, i.e.:

  IF (SUITESPARSE AND SUITESPARSE_FOUND)
    CERES_TEST(compressed_col_sparse_matrix_utils)
    target_link_libraries(compressed_col_sparse_matrix_utils_test ${SUITESPARSE_LIBRARIES})
  ENDIF (SUITESPARSE AND SUITESPARSE_FOUND)

Original issue reported on code.google.com by ston...@yujinrobot.com on 14 Jan 2015 at 2:24

GoogleCodeExporter commented 9 years ago

Original comment by sameerag...@google.com on 14 Jan 2015 at 4:53

GoogleCodeExporter commented 9 years ago
Interesting, so it is true that compressed_col_sparse_matrix_utils_test does 
create a cholmod type and indirectly, #includes cholmod.h, so it should really 
be linking directly to it.  However, I cannot replicate this on by 12.04 
machine using GCC (or Clang), but I note that my link command is:

/usr/bin/c++    -fopenmp -Werror=all -Werror=extra -Wno-unknown-pragmas 
-Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -O3 
-DNDEBUG     
CMakeFiles/compressed_col_sparse_matrix_utils_test.dir/compressed_col_sparse_mat
rix_utils_test.cc.o  -o ../../bin/compressed_col_sparse_matrix_utils_test 
-rdynamic ../../lib/libtest_util.so ../../lib/libceres.so.1.10.0 
../../lib/libgtest.so /usr/local/lib/libgflags.so /usr/local/lib/libglog.so 
-Wl,-rpath,/home/alexs/code/ceres-solver/build-master/lib:/usr/local/lib

Note the last part:  
-rpath,/home/alexs/code/ceres-solver/build-master/lib:/usr/local/lib

Stonier's has only: -rpath,/home/snorri/tmp/ceres-solver/build/lib

which is missing the location of the SuiteSparse libraries, which appear to be 
in: /usr/lib/x86_64-linux-gnu.  That said I think we are getting lucky here as 
my SuiteSparse build is the default static library option, even though Ceres is 
then built as a shared library, but Stonier has clearly built SuiteSparse as a 
shared library.  As such, and as we mark SuiteSparse as private dependencies of 
Ceres, their location is not added to the rpath when they are shared, but it is 
when they are static.

Good find - I will patch this in master now.

Original comment by alexs....@gmail.com on 14 Jan 2015 at 8:58

GoogleCodeExporter commented 9 years ago
This should be fixed in the master branch.
Thanks Alex.

Original comment by sandwich...@gmail.com on 14 Jan 2015 at 9:55