caffe编译matlab接口的问题解决。

来源:互联网 发布:大连网络建站 编辑:程序博客网 时间:2024/06/07 18:55
shawn@shawn-ThinkStation-P700:~/caffe$ make matcaffeMEX matlab/+caffe/private/caffe_.cpp使用 'g++' 编译。/home/shawn/caffe/matlab/+caffe/private/caffe_.cpp: 在函数‘void delete_solver(int, mxArray**, int, const mxArray**)’中:/home/shawn/caffe/matlab/+caffe/private/caffe_.cpp:208:3: 警告: lambda expressions only available with -std=c++11 or -std=gnu++11 [默认启用]/home/shawn/caffe/matlab/+caffe/private/caffe_.cpp:208:4: 错误: 对‘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> >&)>)’的调用没有匹配的函数/home/shawn/caffe/matlab/+caffe/private/caffe_.cpp:208:4: 附注: 备选是:In file included from /usr/include/c++/4.7/algorithm:63:0,                 from ./include/caffe/blob.hpp:4,                 from ./include/caffe/caffe.hpp:7,                 from /home/shawn/caffe/matlab/+caffe/private/caffe_.cpp:18:/usr/include/c++/4.7/bits/stl_algo.h:1166:5: 附注: template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)/home/shawn/caffe/matlab/+caffe/private/caffe_.cpp:208:4: 错误: ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’的模板实参使用了局部类型‘delete_solver(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Solver<float> >&)>’/home/shawn/caffe/matlab/+caffe/private/caffe_.cpp:208:4: 错误:   试图实例化‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’/home/shawn/caffe/matlab/+caffe/private/caffe_.cpp: 在函数‘void delete_net(int, mxArray**, int, const mxArray**)’中:/home/shawn/caffe/matlab/+caffe/private/caffe_.cpp:293:3: 警告: lambda expressions only available with -std=c++11 or -std=gnu++11 [默认启用]/home/shawn/caffe/matlab/+caffe/private/caffe_.cpp:293:4: 错误: 对‘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> >&)>)’的调用没有匹配的函数/home/shawn/caffe/matlab/+caffe/private/caffe_.cpp:293:4: 附注: 备选是:In file included from /usr/include/c++/4.7/algorithm:63:0,                 from ./include/caffe/blob.hpp:4,                 from ./include/caffe/caffe.hpp:7,                 from /home/shawn/caffe/matlab/+caffe/private/caffe_.cpp:18:/usr/include/c++/4.7/bits/stl_algo.h:1166:5: 附注: template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)/home/shawn/caffe/matlab/+caffe/private/caffe_.cpp:293:4: 错误: ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’的模板实参使用了局部类型‘delete_net(int, mxArray**, int, const mxArray**)::<lambda(const boost::shared_ptr<caffe::Net<float> >&)>’/home/shawn/caffe/matlab/+caffe/private/caffe_.cpp:293:4: 错误:   试图实例化‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’make: *** [matlab/+caffe/private/caffe_.mexa64] 错误 255

在http://www.th7.cn/system/lin/201703/207561.shtml找到解决方案:

在Makefile.config里面添加:

CXXFLAGS += -MMD -MP CXXFLAGS += -std=c++11
然后再次编译就正确了:

shawn@shawn-ThinkStation-P700:~/caffe$ make matcaffeMEX matlab/+caffe/private/caffe_.cpp使用 'g++' 编译。MEX 已成功完成。



原创粉丝点击