1. 程式人生 > >caffe編譯Matlab介面報錯:208: 4: error: no matching function for call to remove_if

caffe編譯Matlab介面報錯:208: 4: error: no matching function for call to remove_if

caffe編譯Matlab介面報錯:208:4: error: no matching function for call to remove_if(std::vector

問題:

MEX matlab/+caffe/private/caffe_.cpp
Building with 'g++'.
Warning: You are using gcc version '4.8.2'. 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/zhangyq/caffe-master/matlab/+caffe/private
/caffe_.cpp: In function ‘void delete_solver(int, mxArray**, int, const mxArray**)’: /home/zhangyq/caffe-master/matlab/+caffe/private/caffe_.cpp:208:3: warning: lambda expressions only available with -std=c++11 or -std=gnu++11 [enabled by default] }), solvers_.end()); ^ /home/zhangyq/caffe-master/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**)::__lambda0)’ }), solvers_.end
()); ^ /home/zhangyq/caffe-master/matlab/+caffe/private/caffe_.cpp:208:4: note: candidate is: In file included from /usr/include/c++/4.8.2/algorithm:62:0, from ./include/caffe/blob.hpp:4, from ./include/caffe/caffe.hpp:7, from /home/zhangyq/caffe-master/matlab/+caffe/private/caffe_.cpp:18: XCODE_CLT_GEQ_7 := $(shell [ $(XCODE_CLT_VER) -gt 6 ] && echo 1) /usr/include/c++/4.8.2/bits/stl_algo.h:1134:5: note: template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate) remove_if(_ForwardIterator __first, _ForwardIterator __last, ^ /usr/include/c++/4.8.2/bits/stl_algo.h:1134:5: note: template argument deduction/substitution failed: /home/zhangyq/caffe-master/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**)::__lambda0]’: /home/zhangyq/caffe-master/matlab/+caffe/private/caffe_.cpp:208:4: required from here /home/zhangyq/caffe-master/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**)::__lambda0’ }), solvers_.end()); ^ /home/zhangyq/caffe-master/matlab/+caffe/private/caffe_.cpp:208:4: error: trying to instantiate ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’ /home/zhangyq/caffe-master/matlab/+caffe/private/caffe_.cpp: In function ‘void delete_net(int, mxArray**, int, const mxArray**)’: /home/zhangyq/caffe-master/matlab/+caffe/private/caffe_.cpp:293:3: warning: lambda expressions only available with -std=c++11 or -std=gnu++11 [enabled by default] }), nets_.end()); ^ /home/zhangyq/caffe-master/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**)::__lambda1)’ }), nets_.end()); ^ /home/zhangyq/caffe-master/matlab/+caffe/private/caffe_.cpp:293:4: note: candidate is: In file included from /usr/include/c++/4.8.2/algorithm:62:0, from ./include/caffe/blob.hpp:4, from ./include/caffe/caffe.hpp:7, from /home/zhangyq/caffe-master/matlab/+caffe/private/caffe_.cpp:18: /usr/include/c++/4.8.2/bits/stl_algo.h:1134:5: note: template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate) remove_if(_ForwardIterator __first, _ForwardIterator __last, ^ /usr/include/c++/4.8.2/bits/stl_algo.h:1134:5: note: template argument deduction/substitution failed: /home/zhangyq/caffe-master/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**)::__lambda1]’: /home/zhangyq/caffe-master/matlab/+caffe/private/caffe_.cpp:293:4: required from here /home/zhangyq/caffe-master/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**)::__lambda1’ }), nets_.end()); ^ /home/zhangyq/caffe-master/matlab/+caffe/private/caffe_.cpp:293:4: error: trying to instantiate ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’ make: *** [matlab/+caffe/private/caffe_.mexa64] Error 255

解決方案:

在Makefile裡面CXXFLAGS += -MMD -MP,下面新增CXXFLAGS += -std=c++11
即:

CXXFLAGS += -MMD -MP
CXXFLAGS += -std=c++11