错误显示:
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
部分error:
/home/yjq/Downloads/ceres-solver-master/include/ceres/jet.h:204:13: error: specialization of ‘template<class ... _Tp> struct std::common_type’ in different namespace [-fpermissive]
struct std::common_type<ceres::Jet<T, N>, U> {
^
In file included from /usr/include/c++/5/bits/move.h:57:0,
from /usr/include/c++/5/bits/stl_pair.h:59,
from /usr/include/c++/5/bits/stl_algobase.h:64,
from /usr/include/c++/5/memory:62,
from /home/yjq/Downloads/ceres-solver-master/include/ceres/autodiff_cost_function.h:128,
from /home/yjq/Downloads/ceres-solver-master/include/ceres/ceres.h:37,
from /home/yjq/Downloads/ceres-solver-master/examples/rosenbrock.cc:31:
/usr/include/c++/5/type_traits:2123:12: error: from definition of ‘template<class ... _Tp> struct std::common_type’ [-fpermissive]
struct common_type;
^
In file included from /home/yjq/Downloads/ceres-solver-master/include/ceres/internal/autodiff.h:153:0,
from /home/yjq/Downloads/ceres-solver-master/include/ceres/autodiff_cost_function.h:130,
from /home/yjq/Downloads/ceres-solver-master/include/ceres/ceres.h:37,
from /home/yjq/Downloads/ceres-solver-master/examples/rosenbrock.cc:31:
/home/yjq/Downloads/ceres-solver-master/include/ceres/jet.h:209:13: error: specialization of ‘template<class ... _Tp> struct std::common_type’ in different namespace [-fpermissive]
struct std::common_type<ceres::Jet<T, N>, ceres::Jet<U, N>> {
^
In file included from /usr/include/c++/5/bits/move.h:57:0,
from /usr/include/c++/5/bits/stl_pair.h:59,
from /usr/include/c++/5/bits/stl_algobase.h:64,
from /usr/include/c++/5/memory:62,
from /home/yjq/Downloads/ceres-solver-master/include/ceres/autodiff_cost_function.h:128,
from /home/yjq/Downloads/ceres-solver-master/include/ceres/ceres.h:37,
解决方法:
错误原因为编译器版本过低,我编译出错是版本为gcc-5。利用下面代码查看编译器版本
gcc -v
g++ -v
将编译器默认版本改为7即可,在终端输入下面代码
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-7
sudo apt-get install g++-7
配置:将gcc7,g++7作为默认选项
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100
sudo update-alternatives --config gcc
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 100
sudo update-alternatives --config g++
再次查看编译器版本,无误后再次进行cmake.. 与make。