linux下使用Eclipse编译调试C++ makefile项目

来源:互联网 发布:h3c添加端口到vlan 编辑:程序博客网 时间:2024/06/04 17:56

从网上下到的C++源码基本上都是带makefile的project。对于此类project我们可以使用eclipse进行编译和调试


1)下载安装eclipse C++

sudo apt-get install eclipse eclipse-cdt g++


2)git clone 源码


3)ecplipse导入源码

file->new->c++->打开一个makefile工程


4)./configure出makefile

以我参与的数据库项目peloton为例

  1. Run bootstrap

    ./bootstrap  
  2. Go the build directory and run configure


    cd build../configure  CXXFLAGS="-g -ggdb -O0" --enable-debug
  3. Build and install Peloton

    make -j4  sudo make -j4 install
  4. Update paths

    export PATH=/usr/local/peloton/bin:$PATHexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib


大的project因为涉及到库之类的,所以先安装一遍


5)在eclipse左边资源管理器中的build文件夹下找到makefile文件,右键->make target->create->-j4

这样就相当于make -j4

也可以all,相当于make all


我的项目里还用到:

V=1

check -j4


6)在eclipse左边资源管理器中右键,选择Debug,列表中选择你想debug的可执行文件,本例中为peloton

如果没有virtual binareis就找不到可执行文件,要设置一下:

Project->Properties->C/C++ Build->Settings->Binary Parsers, In Linux I use Elf parser.

如果是windows:

PE Windows Parser (or you can select Cygwin if you use that compiler).


7)在eclipse左边资源管理器中右键,选择Debug Configuration

在参数中输入 peloton对应的参数:-D /home/michael/peloton/build/data


到此为止,配置完毕可以debug了


8)遇到的问题

有时可能遇到库文件找不到的错误,用下面方法解决

ldconfig /usr/local/cuda/lib

参考阅读:

http://blog.csdn.net/linuxarmsummary/article/details/41596579


0 0