linghaiyan 发表于 2015-9-10 09:47:34

在Eclipse之中调试FastDFS-storage

  FDFS版本为5.03
  1、首先在eclipse之中创建一个C/C++工程,取名为FastDFS_v5.03
  2、将FastDFS源码解压后拷贝到新创建的工程目录下,然后在ecipse之中刷新下工程就可以看到新拷贝如的文件如下:

  3、修改工程目录下的make.sh,增加定位到绝对目录,并且去除编译优化(使得程序按照顺序执行)
  1)在make.sh的开头添加两行



cd /Users/bigfish/Documents/workspace/c++/FastDFS_v5.03(修改成绝对路径)
pwd

  2)去除编译优化



CFLAGS='-Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE'
if [ "$DEBUG_FLAG" = "1" ]; then
CFLAGS="$CFLAGS -g -O0 -DDEBUG_FLAG"      
else
CFLAGS="$CFLAGS -O3"
fi

---在第三行-O后面添加一个零即可
  4、修改代码在以debug方式运行时不要进入daemon方式
  1)修改storage/fdfs_storaged.c文件,修改如下:



#ifndef DEBUG_FLAG
daemon_init(false);
#endif
--红色部分为添加,如果为DEBUG则不要进入daemon方式运行

  5、配置eclipse
  1)选择项目属性 C/C++ Build页面,去除Use Default build command的选项,在build command文本框中输入编译命令



sh /Users/bigfish/Documents/workspace/c++/FastDFS_v5.03/make.sh
--路径根据自己设置

  2)选择项目属性 C/C++ General —> Paths and Symbols---> Includes--> GNU C 添加编译时包括的路径



/Users/bigfish/Documents/workspace/c++/FastDFS_v5.03/storage/fdht_client
/Users/bigfish/Documents/workspace/c++/FastDFS_v5.03/tracker
/Users/bigfish/Documents/workspace/c++/FastDFS_v5.03/client
/Users/bigfish/Documents/workspace/c++/FastDFS_v5.03/storage
/Users/bigfish/Documents/workspace/c++/FastDFS_v5.03/common
--根据自己的路径设置


  3)选择项目属性 Run/Debug Settings 新创建一个运行命令
  在Main --> C/C++ Applications 文本框输入执行的程序



/Users/bigfish/Documents/workspace/c++/FastDFS_v5.03/storage/fdfs_storaged


  在Arguments --> Program Arguments 文本框中输入启动参数



/Users/bigfish/Documents/workspace/c++/FastDFS_v5.03/conf/storage.conf


  
  好了,完成。
  
  
  
页: [1]
查看完整版本: 在Eclipse之中调试FastDFS-storage