Sunday, July 29, 2018
Caffe on Ubuntu Eclipse C C
Caffe on Ubuntu Eclipse C C
Purpose
After building Caffe framework, you can use Eclipse to develop and build your own application by including Caffe. Here is a article to teach you how to setup Eclipse for Caffe on Ubuntu14.04 and Eclipse C/C++.Step 1:
Open Eclipse, create a C++ project, and select Linux GCC toolchains.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjANFUfTnmHJBF1Y_Oer8seb-_XlpHbUJZcKQXDoClOY-V4Jl1zgOpVudPbSnC4tHk0R_bDwGwKWq5oYavsMladqD8VNgRVtvBPvu24jki1BUcOCCKUgG4WbHkFJHqfXz2jxuw2mpsUaTr/s400/0.png)
Step2:
Go to "properties->C/C++ Build->Settings-> GCC C++ Compiler ->includes" to set Caffes include path. Add two paths to be included:
to/your/path/caffe/include
to/your/path/caffe/distribute/include
Notes: Whenever Caffe releases, need to run all build cmds
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3dRcwZJBsjo9Iw1MPE48gp0Bsnai2UrKU6KPCIsh2NQ4x_N5JzN0vyuxTwytzqDamBiJ2TuXP7KO2VJ7-TbmUhDzzQMzXvl2EgZbwrrc3LDr5UaNnc0oKWr9TNIt8efUS22yMikYYnvbH/s400/2.png)
Step3:
Go to "properties->C/C++ Build->Settings-> GCC C++ Linker ->Libraries" to set Caffes libray path.
Add the bellows to "Library search path(-L)"
to/your/path/caffe/build/lib
Paste it to " include path(-l) "
caffe
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhj9PziBkVPoVZ9VtNLDfMvu_f9f_vPUauL1nrT4bDEUOCuy9qh5NQoCQGdgFeyNb3bjuc0bKj6vznNr0UxQAMmyog0XldcrH7SPM3Bvu2WmUIg9DKUGrvdwkSOf9D5rWP6i_zhBapom33p/s400/3.png)
Step4: (Optional)
Because I didnt use GPU to compute, so I set CPU_ONLY=1 for preprocessor.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiABLxBrEo6g6IJbczIaYB-BSZIzL7gvstx6RbwXftI6WwDb4ynuQoQ0ZLuCDAXHKJEIeN8bP2oqGoqL_qpoeMD2pqCKFx124zkbibJd5h54Ge-WdxZszP4SZim8JtIQkNjqQgw0VgRArGr/s400/1.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtbVFRcupbTzVt_u_Cazwvt1mP3JA7x0wGi0hHrN4UIFm_VpOVIstbHO-b_sPyO0zpVMyHf0UE2pfMCxW2WCt8BcUrO-Wrbl8AUxsduVIW8TWjQ730baVg9qxxJ2ANknwiExG2bVqqPK2g/s400/Screenshot+from+2015-08-19+21%253A32%253A31.png)
Step5:
To let Linker find libcaffe.so , you need to specify libcaffe.so in Properties->C/C++ Build->Setting->GCC C++ Linker->Miscellaneous->Other objects
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirVPqynjCxNcqsZ5I20wK2ZuhBxbEaw68m7dW13ly9CjH9YKqGciRx1BJ98Qsu0KfHWLVu3WMmw-OGQtlg2qyYCCJ4avm8TSpOKGw2qnTGezwotTAFZPDuyTk2XHRQKUutJIicFJLP7ZZX/s400/Screenshot+from+2015-08-25+15%253A02%253A44.png)
If you does not want specify libcaffe.so in Eclipse.
You can Set LD_LIBRARY_PATH to ~.bashrc to find libcaffe for linker
$ echo export LD_LIBRARY_PATH="to/your/path/caffe/build/lib/" > ~/.bashrc
In my case:
export LD_LIBRARY_PATH="/lib:/usr/lib:/usr/local/lib:/home/darrenl/developments/caffe/build/lib/"
Step6:
Add a *.cpp file and include caffe.hpp to build.
#include <caffe/caffe.hpp>
using caffe::Blob;
using caffe::Caffe;
using caffe::Datum;
using caffe::Net;
using caffe::shared_ptr;
using caffe::vector;
using caffe::MemoryDataLayer;
int main() {
Net<float> *caffe_net;
return 0;
}
You can refer to my source code:$ git clone https://github.com/tzutalin/caffe_test.git
Build and Run
Build: Project-> Build Project (ctrl + b)
Run: Run as Local C++ application (ctrl + F11)
Others:
You can refer to the blog to setup and build Caffe from scratchhttp://tzutalin.blogspot.tw/2015/06/setup-caffe.html
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.