Hi,
I'm trying to compile ceres with gcc 4.1.2 (to match the version used to compile ATLAS on my system, since the gfortran versions have to match).
I am getting:
[ 0%] Building CXX object internal/ceres/CMakeFiles/gtest.dir/gmock_gtest_all.cc.o
/home/dstn/software/ceres-solver-1.7.0/internal/ceres/gmock_gtest_all.cc:1: error: bad value (native) for -march= switch
/home/dstn/software/ceres-solver-1.7.0/internal/ceres/gmock_gtest_all.cc:1: error: bad value (native) for -mtune= switch
make[2]: *** [internal/ceres/CMakeFiles/gtest.dir/gmock_gtest_all.cc.o] Error 1
In my cmake command I have:
-DCMAKE_C_FLAGS=-fPIC -DCMAKE_CXX_FLAGS=-fPIC
It looks like you're doing:
/home/dstn/software/ceres-solver-1.7.0/CMakeLists.txt(601): IF(CMAKE_SYSTEM_NAME MATCHES Linux )
/home/dstn/software/ceres-solver-1.7.0/CMakeLists.txt(602): SET(CERES_CXX_FLAGS ${CERES_CXX_FLAGS} -march=native -mtune=native )
but -march=native didn't appear until a fairly recent gcc release.
Editing CMakeLists.txt around line 600 (just commenting-out those lines) fixes it.
Almost.
Later I get:
cc1plus: warnings being treated as errors
/home/dstn/software/ceres-solver-1.7.0/internal/ceres/lapack.cc: In static member function 'static int ceres::internal::LAPACK::EstimateWorkSizeForQR(int, int)':
/home/dstn/software/ceres-solver-1.7.0/internal/ceres/lapack.cc:117: warning: converting to 'int' from 'double'
make[2]: *** [internal/ceres/CMakeFiles/ceres.dir/lapack.cc.o] Error 1
Which looks like a legitimate complaint...
Removing -Werror, it compiles. Hoorah!
With all this, I am able to compile ceres and link it with my python module, via:
swig -python -c++ -I/clusterfs/riemann/software/numpy/1.6.1-2.7.2/lib/python2.7/site-packages/numpy/core/include -I/home/dstn/software/glog-0.3.3/include -I/home/dstn/software/ceres-solver-1.7.0/include -I/home/dstn/software/eigen -I/usr/local/include/eigen3 ceres.i
g++ -Wall -fPIC -c ceres_wrap.cxx $(python-config --includes) -I/clusterfs/riemann/software/numpy/1.6.1-2.7.2/lib/python2.7/site-packages/numpy/core/include -I/home/dstn/software/glog-0.3.3/include -I/home/dstn/software/ceres-solver-1.7.0/include -I/home/dstn/software/eigen -I/usr/local/include/eigen3
g++ -Wall -fPIC -c ceres-tractor.cc -I/home/dstn/software/glog-0.3.3/include -I/home/dstn/software/ceres-solver-1.7.0/include -I/home/dstn/software/eigen -I/usr/local/include/eigen3
g++ -Wall -fPIC -o _ceres.so -shared ceres_wrap.o ceres-tractor.o /home/dstn/software/ceres-solver-1.7.0/lib/libceres.a /home/dstn/software/suitesparse-4.1.2/lib/lib{cholmod,amd,camd,colamd,ccolamd,suitesparseconfig,metis}.a /clusterfs/riemann/software/ATLAS/3.8.3/lib/lib{lapack,f77blas,atlas,cblas}.a -L/home/dstn/software/glog-0.3.3/lib -lglog -lgfortran -lrt
Note that the order of the .a files is important! Otherwise you get failure to resolve symbols when the library is loaded.
cheers,
dustin