转自:http://blog.csdn.net/yaoxingfu72/article/details/47999795

首先确保你caffe编译成功,而且makefile.config中将DEBUG:=1那一行取消注释,我的caffe根目录为 caffe-master。你也可以在Eclipse中编译caffe,我是先编译好caffe,然后进入Eclipse中调试


1、eclipse 下载网址http://www.eclipse.org/downloads/

下载eclipse IDE for c/c++.(注意无需下载jre等安装包,直接下载链接中的 c++版的Eclipse即可)

下载完成后进入下载目录:tar -zxvf eclipse-cpp-mars-R-Linux-gtk-x86_64.tar.gz

进入解压目录eclipse,打开 eclipse 软件。

2.导入caffe makefile工程到eclipse (由于是英文版,下面描述也用英文,省的翻译,方便大家调试)

(1)File→New→Project→C/C++ →Makefile Project with Existing Code.

caffe调试 ubuntu1404+eclipsecaffe调试 ubuntu1404+eclipse

(2)Create a new Makefile Project from existing code

Projectname:

 caffe-master
Existing code location
   /home/user/caffe-workspace/caffe-master
Language:
   choose C and C++
Toolchain:
  choose
linux
GCC

caffe调试 ubuntu1404+eclipse

(3)Then click on caffe-master in Project Explorer (set Window→Open  Perspective → C/C++).

caffe调试 ubuntu1404+eclipsecaffe调试 ubuntu1404+eclipse

(4)Now
Go
File → Properties → Run/Debug settings.Click  New.., and choose C/C++ application

caffe调试 ubuntu1404+eclipse

(5)Fill launch configurationproperties

caffe调试 ubuntu1404+eclipsecaffe调试 ubuntu1404+eclipse

·        Arguments:
fill  
train –solver=examples/mnist/lenet_solver.prototxt
and change working directory from default to /home/user/caffe-workspace/caffe-master(change to your own directory)

caffe调试 ubuntu1404+eclipse

(6)Now you can use debug caffe code: Run-> Debug: 

caffe调试 ubuntu1404+eclipse
caffe调试 ubuntu1404+eclipse

注:Eclipse中调试技巧大家可以百度,可以在eclipse中打开src文件中layer层的原函数,在每行前面设置断点进行调试。常用命令 F5进入函数内部 F6单步运行(不进入函数内部)F8运行到下一断点处