Ubuntu16.04下环境配置Caffe

caffe装matlab接口报错: recipe for target ‘matlab/+caffe/private/caffe_.mexa64’ failed

MEX matlab/+caffe/private/caffe_.cpp
Building with 'g++'.
Warning: You are using gcc version '5.4.0'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.
Warning: You are using gcc version '5.4.0-6ubuntu1~16.04.4)'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp: In function ‘void delete_solver(int, mxArray**, int, const mxArray**)’:
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:208:3: warning: lambda expressions only available with -std=c++11 or -std=gnu++11
   }), solvers_.end());
   ^
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:208:4: error: no matching function for call to ‘remove_if(std::vector<boost::shared_ptr<caffe::Solver<float> > >::iterator, std::vector<boost::shared_ptr<caffe::Solver<float> > >::iterator, delete_solver(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Solver<float> >&)>)’
   }), solvers_.end());
    ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from ./include/caffe/blob.hpp:4,
                 from ./include/caffe/caffe.hpp:7,
                 from /home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:18:
/usr/include/c++/5/bits/stl_algo.h:926:5: note: candidate: template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)
     remove_if(_ForwardIterator __first, _ForwardIterator __last,
     ^
/usr/include/c++/5/bits/stl_algo.h:926:5: note:   template argument deduction/substitution failed:
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp: In substitution of ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate) [with _FIter = __gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Solver<float> >*, std::vector<boost::shared_ptr<caffe::Solver<float> > > >; _Predicate = delete_solver(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Solver<float> >&)>]’:
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:208:4:   required from here
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:208:4: error: template argument for ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’ uses local type ‘delete_solver(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Solver<float> >&)>’
   }), solvers_.end());
    ^
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:208:4: error:   trying to instantiate ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp: In function ‘void delete_net(int, mxArray**, int, const mxArray**)’:
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:293:3: warning: lambda expressions only available with -std=c++11 or -std=gnu++11
   }), nets_.end());
   ^
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:293:4: error: no matching function for call to ‘remove_if(std::vector<boost::shared_ptr<caffe::Net<float> > >::iterator, std::vector<boost::shared_ptr<caffe::Net<float> > >::iterator, delete_net(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Net<float> >&)>)’
   }), nets_.end());
    ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from ./include/caffe/blob.hpp:4,
                 from ./include/caffe/caffe.hpp:7,
                 from /home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:18:
/usr/include/c++/5/bits/stl_algo.h:926:5: note: candidate: template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)
     remove_if(_ForwardIterator __first, _ForwardIterator __last,
     ^
/usr/include/c++/5/bits/stl_algo.h:926:5: note:   template argument deduction/substitution failed:
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp: In substitution of ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate) [with _FIter = __gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Net<float> >*, std::vector<boost::shared_ptr<caffe::Net<float> > > >; _Predicate = delete_net(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Net<float> >&)>]’:
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:293:4:   required from here
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:293:4: error: template argument for ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’ uses local type ‘delete_net(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Net<float> >&)>’
   }), nets_.end());
    ^
/home/mcs/caffe/matlab/+caffe/private/caffe_.cpp:293:4: error:   trying to instantiate ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’

Makefile:517: recipe for target 'matlab/+caffe/private/caffe_.mexa64' failed
make: *** [matlab/+caffe/private/caffe_.mexa64] Error 255

一开始以为是warning中说明的问题,即gcc版本不兼容导致的,Ubuntu 16.04默认gcc版本是5.4,后来换成gcc-4.7,caffe却无法编译了,主要问题出在protobuf中。后来又尝试了使用gcc-5编译caffe,然后换成gcc-4.7,编译matcaffe时,出现另一个错误,问题好像还是protobuf编译出错。之后又尝试了从源码安装protobuf,想换高版本的MATLAB,总之坑了好久,都没解决问题。

http://www.caffecn.cn/?/question/1113中,终于找到解决方案:

修改makefile里面的CXXFLAGS,添加CXXFLAGS += -std=c++11.然后重新编译就可以了。
即:在那一句话下面添加,如下这样
CXXFLAGS += -MMD -MP
CXXFLAGS += -std=c++11

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值