Caffe學習筆記(6)----matlab接口的編譯。。淚千行


matlab接口的編譯真是淚千行。。。本來我是不用matlab的 ,但是帶我的師兄只用matlab,為了學習他的程序我不得不編譯接口。。。

make  matcaffe之后一開始就出現了gcc版本不合的問題,這個我猜大部分人都遇到過

目前caffe只支持4.7版本

因此我們要降級gcc和g++

 我用的就是這位博主的方法,查了很多其他的方法都沒用。。。各位看官可以去圍觀一波。。這個方法我用完就可以編譯了

http://www.cnblogs.com/loveyakamoz/archive/2012/12/26/2833967.html

最棒棒的是這個方法並不會刪除gcc版本,以后你想升回來很方便!是不是很棒棒!

把gcc編譯好之后又遇到了另一個問題

 1 $make matcaffe -j8
 2 MEX matlab/+caffe/private/caffe_.cpp
 3 使用 'g++' 編譯。
 4 /home/zkk/caffe/matlab/+caffe/private/caffe_.cpp: In function ‘void delete_solver(int, mxArray**, int, const mxArray**)’:
 5 /home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:208:3: warning: lambda expressions only available with -std=c++11 or -std=gnu++11 [enabled by default]
 6 /home/zkk/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> >&)>)’
 7 /home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:208:4: note: candidate is:
 8 In file included from /usr/include/c++/4.7/algorithm:63:0,
 9                  from ./include/caffe/blob.hpp:4,
10                  from ./include/caffe/caffe.hpp:7,
11                  from /home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:18:
12 /usr/include/c++/4.7/bits/stl_algo.h:1166:5: note: template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)
13 /home/zkk/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> >&)>14 /home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:208:4: error:   trying to instantiate ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’
15 /home/zkk/caffe/matlab/+caffe/private/caffe_.cpp: In function ‘void delete_net(int, mxArray**, int, const mxArray**)’:
16 /home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:293:3: warning: lambda expressions only available with -std=c++11 or -std=gnu++11 [enabled by default]
17 /home/zkk/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> >&)>)’
18 /home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:293:4: note: candidate is:
19 In file included from /usr/include/c++/4.7/algorithm:63:0,
20                  from ./include/caffe/blob.hpp:4,
21                  from ./include/caffe/caffe.hpp:7,
22                  from /home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:18:
23 /usr/include/c++/4.7/bits/stl_algo.h:1166:5: note: template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)
24 /home/zkk/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> >&)>25 /home/zkk/caffe/matlab/+caffe/private/caffe_.cpp:293:4: error:   trying to instantiate ‘template<class _FIter, class _Predicate> _FIter std::remove_if(_FIter, _FIter, _Predicate)’
26 
27 Makefile:518: recipe for target 'matlab/+caffe/private/caffe_.mexa64' failed
28 make: *** [matlab/+caffe/private/caffe_.mexa64] Error 255

各種百度無果。。。最后在caffe中文社區上找到的方法,,跟我一模一樣的問題

 

解決辦法是:

       在Makefile里面,大約第410行那一句話

CXXFLAGS += -MMD -MP

下面添加CXXFLAGS += -std=c++11,

最后是這樣 CXXFLAGS += -MMD -MP CXXFLAGS += -std=c++11

然后在caffe根目錄下make clean,make all

 

賓果!matlab就這樣順利編譯好啦!!!

看着挺簡單。。。但是我能說我搜了兩三天嗎。。。。。給你們節省不少時間哈。。。。。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM