pritasam / ceres-solver

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

Compiling failed #101

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I used Ceres 1.5 and google log 0.3.3 version on AMD 64 bit machine
2. I followed tutorial and tried to build Ceres from source, and the cmake 
command I use is:

cmake ../ceres-solver-1.5.0 
-DCMAKE_INSTALL_PREFIX="/net/fantasia/home/zhanxw/software/ceres-build/" 
-DGFLAGS_LIB=/net/fantasia/home/zhanxw/software/gflags/lib/libgflags.a 
-DGFLAGS_INCLUDE=/net/fantasia/home/zhanxw/software/gflags/include/ 
-DGLOG_LIB=/net/fantasia/home/zhanxw/software/glog/lib/libglog.a 
-DGLOG_INCLUDE=/net/fantasia/home/zhanxw/software/glog/include/ 
-DEIGEN_INCLUDE=/net/fantasia/home/zhanxw/rvtests/third/eigen

3. I type 'make -j10' and the compilation failed.

What is the expected output? What do you see instead?

I expect the compiling succeed, but I saw this:

[ 60%] Building CXX object 
internal/ceres/CMakeFiles/ceres.dir/generated/schur_eliminator_2_4_d.cc.o
[ 60%] Building CXX object 
internal/ceres/CMakeFiles/ceres.dir/generated/schur_eliminator_4_4_2.cc.o
[ 61%] Building CXX object 
internal/ceres/CMakeFiles/ceres.dir/generated/schur_eliminator_4_4_3.cc.o
[ 61%] Building CXX object 
internal/ceres/CMakeFiles/ceres.dir/generated/schur_eliminator_4_4_4.cc.o
Linking CXX shared library ../../lib/libceres_shared.so
/usr/bin/ld: 
/net/fantasia/home/zhanxw/software/glog/lib/libglog.a(libglog_la-logging.o): 
relocation R_X86_64_32S against `vtable for google::base::Logger' can not be 
used when making a shared object; recompile with -fPIC
/net/fantasia/home/zhanxw/software/glog/lib/libglog.a: could not read symbols: 
Bad value
collect2: ld returned 1 exit status
make[2]: *** [lib/libceres_shared.so.1.5.0] Error 1
make[1]: *** [internal/ceres/CMakeFiles/ceres_shared.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 62%] Building CXX object 
internal/ceres/CMakeFiles/ceres.dir/generated/schur_eliminator_4_4_d.cc.o
[ 62%] Building CXX object 
internal/ceres/CMakeFiles/ceres.dir/generated/schur_eliminator_d_d_d.cc.o
Linking CXX static library ../../lib/libceres.a
[ 68%] Built target ceres
make: *** [all] Error 2

What version of the product are you using? On what operating system?

Ceres 1.5.0
Google log 0.3.3
Google flags 2.0

I am using AMD 64bit system running ubuntu 12.04

Please provide any additional information below.

Original issue reported on code.google.com by zhanxw on 2 May 2013 at 5:12

GoogleCodeExporter commented 9 years ago
Thanks for reporting this.  I am not entirely sure what is happening here. This 
seems to be a glog related issue.
I am adding Keir to this, who may have more of an insight.

Original comment by sameerag...@google.com on 2 May 2013 at 5:31

GoogleCodeExporter commented 9 years ago
Thanks Sameer. I just learnt VERBOSE=1 trick in Ceres email google group, so 
here I pasted the failed command.

Linking CXX shared library ../../lib/libceres_shared.so
cd /net/fantasia/home/zhanxw/software/ceres-build/internal/ceres && 
/usr/bin/cmake -E cmake_link_script CMakeFiles/ceres_shared.dir/link.txt 
--verbose=1
/usr/bin/c++  -fPIC  -fopenmp -Werror -Wall -Wextra -Wno-unknown-pragmas 
-Wno-sign-compare -Wno-unused-parameter -O3 -DNDEBUG  -march=native 
-mtune=native  -march=native -mtune=native  -march=native -mtune=native  
-march=native -mtune=native  -march=native -mtune=native  -march=native 
-mtune=native  -march=native -mtune=native   -lpthread -shared 
-Wl,-soname,libceres_shared.so.1.5.0 -o ../../lib/libceres_shared.so.1.5.0 
CMakeFiles/ceres_shared.dir/matrix.pb.cc.o 
CMakeFiles/ceres_shared.dir/array_utils.cc.o 
CMakeFiles/ceres_shared.dir/block_evaluate_preparer.cc.o 
CMakeFiles/ceres_shared.dir/block_jacobi_preconditioner.cc.o 
CMakeFiles/ceres_shared.dir/block_jacobian_writer.cc.o 
CMakeFiles/ceres_shared.dir/block_random_access_dense_matrix.cc.o 
CMakeFiles/ceres_shared.dir/block_random_access_matrix.cc.o 
CMakeFiles/ceres_shared.dir/block_random_access_sparse_matrix.cc.o 
CMakeFiles/ceres_shared.dir/block_sparse_matrix.cc.o 
CMakeFiles/ceres_shared.dir/block_structure.cc.o 
CMakeFiles/ceres_shared.dir/canonical_views_clustering.cc.o 
CMakeFiles/ceres_shared.dir/cgnr_solver.cc.o 
CMakeFiles/ceres_shared.dir/compressed_row_jacobian_writer.cc.o 
CMakeFiles/ceres_shared.dir/compressed_row_sparse_matrix.cc.o 
CMakeFiles/ceres_shared.dir/conditioned_cost_function.cc.o 
CMakeFiles/ceres_shared.dir/conjugate_gradients_solver.cc.o 
CMakeFiles/ceres_shared.dir/coordinate_descent_minimizer.cc.o 
CMakeFiles/ceres_shared.dir/corrector.cc.o 
CMakeFiles/ceres_shared.dir/cxsparse.cc.o 
CMakeFiles/ceres_shared.dir/dense_normal_cholesky_solver.cc.o 
CMakeFiles/ceres_shared.dir/dense_qr_solver.cc.o 
CMakeFiles/ceres_shared.dir/dense_sparse_matrix.cc.o 
CMakeFiles/ceres_shared.dir/detect_structure.cc.o 
CMakeFiles/ceres_shared.dir/dogleg_strategy.cc.o 
CMakeFiles/ceres_shared.dir/evaluator.cc.o 
CMakeFiles/ceres_shared.dir/file.cc.o 
CMakeFiles/ceres_shared.dir/gradient_checking_cost_function.cc.o 
CMakeFiles/ceres_shared.dir/implicit_schur_complement.cc.o 
CMakeFiles/ceres_shared.dir/iterative_schur_complement_solver.cc.o 
CMakeFiles/ceres_shared.dir/levenberg_marquardt_strategy.cc.o 
CMakeFiles/ceres_shared.dir/line_search.cc.o 
CMakeFiles/ceres_shared.dir/line_search_direction.cc.o 
CMakeFiles/ceres_shared.dir/line_search_minimizer.cc.o 
CMakeFiles/ceres_shared.dir/linear_least_squares_problems.cc.o 
CMakeFiles/ceres_shared.dir/linear_operator.cc.o 
CMakeFiles/ceres_shared.dir/linear_solver.cc.o 
CMakeFiles/ceres_shared.dir/local_parameterization.cc.o 
CMakeFiles/ceres_shared.dir/loss_function.cc.o 
CMakeFiles/ceres_shared.dir/low_rank_inverse_hessian.cc.o 
CMakeFiles/ceres_shared.dir/minimizer.cc.o 
CMakeFiles/ceres_shared.dir/normal_prior.cc.o 
CMakeFiles/ceres_shared.dir/parameter_block_ordering.cc.o 
CMakeFiles/ceres_shared.dir/partitioned_matrix_view.cc.o 
CMakeFiles/ceres_shared.dir/polynomial.cc.o 
CMakeFiles/ceres_shared.dir/preconditioner.cc.o 
CMakeFiles/ceres_shared.dir/problem.cc.o 
CMakeFiles/ceres_shared.dir/problem_impl.cc.o 
CMakeFiles/ceres_shared.dir/program.cc.o 
CMakeFiles/ceres_shared.dir/residual_block.cc.o 
CMakeFiles/ceres_shared.dir/residual_block_utils.cc.o 
CMakeFiles/ceres_shared.dir/runtime_numeric_diff_cost_function.cc.o 
CMakeFiles/ceres_shared.dir/schur_complement_solver.cc.o 
CMakeFiles/ceres_shared.dir/schur_eliminator.cc.o 
CMakeFiles/ceres_shared.dir/schur_jacobi_preconditioner.cc.o 
CMakeFiles/ceres_shared.dir/scratch_evaluate_preparer.cc.o 
CMakeFiles/ceres_shared.dir/solver.cc.o 
CMakeFiles/ceres_shared.dir/solver_impl.cc.o 
CMakeFiles/ceres_shared.dir/sparse_matrix.cc.o 
CMakeFiles/ceres_shared.dir/sparse_normal_cholesky_solver.cc.o 
CMakeFiles/ceres_shared.dir/split.cc.o 
CMakeFiles/ceres_shared.dir/stringprintf.cc.o 
CMakeFiles/ceres_shared.dir/suitesparse.cc.o 
CMakeFiles/ceres_shared.dir/triplet_sparse_matrix.cc.o 
CMakeFiles/ceres_shared.dir/trust_region_minimizer.cc.o 
CMakeFiles/ceres_shared.dir/trust_region_strategy.cc.o 
CMakeFiles/ceres_shared.dir/types.cc.o 
CMakeFiles/ceres_shared.dir/visibility.cc.o 
CMakeFiles/ceres_shared.dir/visibility_based_preconditioner.cc.o 
CMakeFiles/ceres_shared.dir/wall_time.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_2_2_2.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_2_2_3.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_2_2_4.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_2_2_d.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_2_3_3.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_2_3_4.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_2_3_9.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_2_3_d.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_2_4_3.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_2_4_4.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_2_4_d.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_4_4_2.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_4_4_3.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_4_4_4.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_4_4_d.cc.o 
CMakeFiles/ceres_shared.dir/generated/schur_eliminator_d_d_d.cc.o 
/net/fantasia/home/zhanxw/software/glog/lib/libglog.a 
/net/fantasia/home/zhanxw/software/gflags/lib/libgflags.a -lgomp 
/net/fantasia/home/zhanxw/software/protobuf/lib/libprotobuf.a 
/usr/bin/ld: 
/net/fantasia/home/zhanxw/software/glog/lib/libglog.a(libglog_la-logging.o): 
relocation R_X86_64_32S against `vtable for google::base::Logger' can not be 
used when making a shared object; recompile with -fPIC
/net/fantasia/home/zhanxw/software/glog/lib/libglog.a: could not read symbols: 
Bad value
collect2: ld returned 1 exit status
make[2]: *** [lib/libceres_shared.so.1.5.0] Error 1
make[2]: Leaving directory `/net/fantasia/home/zhanxw/software/ceres-build'
make[1]: *** [internal/ceres/CMakeFiles/ceres_shared.dir/all] Error 2
make[1]: Leaving directory `/net/fantasia/home/zhanxw/software/ceres-build'
make: *** [all] Error 2

Original comment by zhanxw on 2 May 2013 at 5:36

GoogleCodeExporter commented 9 years ago
I think your libglog maybe broken. Could you try compiling something  like

#include "glog/logging.h"

int main(int argc, char** argv) {
    google::InitGoogleLogging(argv[0]);
   LOG(INFO) << "Hello World\n";
}

and see if

a.out -logtostderr works?

Original comment by sameerag...@google.com on 2 May 2013 at 5:39

GoogleCodeExporter commented 9 years ago
It seems libglog works...

I created a file like this:

#include "glog/logging.h"

int main(int argc, char** argv) {
    google::InitGoogleLogging(argv[0]);
   LOG(INFO) << "Hello World\n";
   LOG(ERROR) << "Hello World\n";
}

Then I compile and run it:

g++ tmp.cpp -I$HOME/software/glog/include $HOME/software/glog/lib/libglog.a 
-lpthread

 ./a.out --help
E0502 13:56:15.626204 12976 tmp.cpp:6] Hello World

Original comment by zhanxw on 2 May 2013 at 5:58

GoogleCodeExporter commented 9 years ago
actually the problem is that libglog was not compiled with -fPIC which means 
the code in it is not position independent and the linker is barfing. I think 
you need to re-compile your libglog to be shared library friendly.

you could just not build the shared library .. and only work with the static 
library if you want.

"make ceres" 

should do that

Original comment by sameerag...@google.com on 2 May 2013 at 6:08

GoogleCodeExporter commented 9 years ago
I just checked glog is compile with -fPIC flag, as following:

libtool: link: g++  -fPIC -DPIC -shared -nostdlib 
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o 
/usr/lib/gcc/x86_64-linux-gnu/4.6/crtbeginS.o  .libs/libglog_la-logging.o 
.libs/libglog_la-raw_logging.o .libs/libglog_la-vlog_is_on.o 
.libs/libglog_la-utilities.o .libs/libglog_la-demangle.o 
.libs/libglog_la-symbolize.o .libs/libglog_la-signalhandler.o   -lpthread 
-L/usr/lib/gcc/x86_64-linux-gnu/4.6 
-L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu 
-L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib -L/lib/x86_64-linux-gnu 
-L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib 
-L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../.. -lstdc++ -lm -lc -lgcc_s 
/usr/lib/gcc/x86_64-linux-gnu/4.6/crtendS.o 
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crtn.o  -O2   
-Wl,-soname -Wl,libglog.so.0 -o .libs/libglog.so.0.0.0

But I don't bother to deal with glog issue now, as the "make ceres" trick 
works, and I am able to use Ceres now. 
Thanks for your help.

Original comment by zhanxw on 2 May 2013 at 8:42

GoogleCodeExporter commented 9 years ago
Np. I will mark this issue as fixed for now.

Original comment by sameerag...@google.com on 2 May 2013 at 8:47