error: bad value (native) for -march= switch

971 views
Skip to first unread message

Dustin Lang

unread,
Sep 19, 2013, 11:32:19 AM9/19/13
to ceres-...@googlegroups.com
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



Sameer Agarwal

unread,
Sep 19, 2013, 11:48:58 AM9/19/13
to ceres-...@googlegroups.com
sweet. Looks like we need to be more careful about the gcc version in the cmake file.
I will add a fix to that and look at adding an explicit cast in lapack.cc.
Thank you for the report.
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/571a76f0-6ee1-43aa-807b-8a355d9c0f31%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Dustin Lang

unread,
Sep 19, 2013, 11:52:34 AM9/19/13
to ceres-...@googlegroups.com
According to my notes in Astrometry.net, -march=native appear in gcc 4.2

cheers,
--dustin


Sameer Agarwal

unread,
Sep 19, 2013, 1:08:04 PM9/19/13
to ceres-...@googlegroups.com
Dustin,
Can you check if 


fixes the problems for you.

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.

Dustin Lang

unread,
Sep 19, 2013, 1:15:38 PM9/19/13
to ceres-...@googlegroups.com
I get:

...
-- Using normal TR1 unordered_map/set
CMake Error at CMakeLists.txt:606 (IF):
  if given arguments:

    "GCC_VERSION" "NOT" "VERSION_LESS" "4.2"

  Unknown arguments specified


-- Configuring incomplete, errors occurred!



cheers,
--dustin

Sameer Agarwal

unread,
Sep 19, 2013, 1:25:48 PM9/19/13
to ceres-...@googlegroups.com
ugh, silly mistake from me.
updated. please try now.

thanks,
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.

Dustin Lang

unread,
Sep 19, 2013, 1:30:33 PM9/19/13
to ceres-...@googlegroups.com
It works!

Thanks for the quick fix!
--dustin

Sameer Agarwal

unread,
Sep 19, 2013, 1:33:43 PM9/19/13
to ceres-...@googlegroups.com
Great thanks for testing.

Keir will merge this as soon as he has a chance to review it.

BTW, GCC 4.1.2? Your cluster seems to be a bit behind the times.

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.

Dustin Lang

unread,
Sep 19, 2013, 1:47:15 PM9/19/13
to ceres-...@googlegroups.com
> BTW, GCC 4.1.2? Your cluster seems to be a bit behind the times.

Yeah yeah yeah, CentOS release 5.8 (Final)

We do have gcc 4.7 installed also, but I had to match the gcc version to the version used to compile ATLAS.

--dstn


Sameer Agarwal

unread,
Sep 19, 2013, 7:27:01 PM9/19/13
to ceres-...@googlegroups.com
This has been fixed on the master branch.
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.
Reply all
Reply to author
Forward
0 new messages