ubuntu16.04安装ceres时make出错

错误显示:

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。

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阿巴乾

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值