将已有makefile的工程导入到eclipse

将已有makefile的工程导入到eclipse


Eclipse CDT导入已有的C/C++工程
    1. 下载C/C++工程源码,解压,然后进入目录,执行configure命令生成Makefile。
    2. Eclipse:
              “File”->“New”->“Makefile  Project with Existing Code”。
              注:项目目录要首先复制到位,注意备份。
    3. 项目建立完毕后就可以利用生成的Makefile进行build。
参考:http://blog.163.com/jianlizhao@126/blog/static/1732511632013310115218806
http://www.crifan.com/under_ubuntu_compile_project_using_eclipse/


Eclipse CDT 导入 Makefile 构建的 C/C++ 工程
作者:柳大·Poechant(钟超)
邮箱:zhongchao.ustc#gmail.com(# -> @)
博客:Blog.CSDN.net/Poechant
日期:June 30th, 2012
我是在 Mac OS X 上使用的 Eclipse CDT,Linux 和 Windows 版本的也相类似,一般只是 Preference 的位置不同。


File -> New -> Makefile Project with Existing Code
选择源码目录,语言选择C语言。如果是 Linux 环境,则选中 Linux GCC,Mac 环境则选择 MacOSX GCC,Windows 下用 Eclipse 则可以选择 MinGW GCC。
Project -> Make Target -> Create,建立 all 和 clean 两个 Targets。
在 Make Target 的 View 里面选择刚刚建立的项目的 all 来构建项目
构建结束后,Run -> Debug As -> Local C/C++ Application -> gdb/mi,调试选项可以在 Debug Configuration 中设置。
其中 gdb/mi 和 gdb 的区别,在网上搜来如下解释:


gdb and gdb/mi are essentially the same, except that gdb/mi lets you
select the MI protocol version and command set to use (MI - or Machine 
Interface - is how Eclipse communicates with gdb, rather than using 
the normal gdb command-line interface). This is useful if you want to 
do something not supported by the defaults, or have a non-standard gdb,
such as used on Mac OS X. gdbserver is a very lightweight debug server
used for debugging embedded systems. **The normal gdb/mi commands are 
used, but gdb must be told to connect to a gdbserver running on a remote 
system.** There's an extra tab for specifying this information.
Reference:


http://dev.eclipse.org/mhonarc/lists/photran/msg00926.html
http://blog.csdn.net/kevin_zqw/article/details/6927151






首先看提示信息 产生的背景make: *** No rule to make target `all'.  Stop


在eclipse上创建一个c project(注意:Project type:  Makefile Project下的Empty Project)


添加c语言文件
编辑自己的makefile
点击project->clean 清除编译产生的文件
点击project->build project  就会出现这个错误


原因


首先从提示可知道 Current Project没有办法make taget ‘all’,那么很可能就是Current Project 的编译设置不对导致的。


其次,在IDE上找到配置Current Project Build的地方,在Project->Properties->C/C++ Build。


最后,在C/C++ Build中的Behavior Tab(行为or规则)标签下,看到一个Build(Incremental build)CheckBox和一个文本框(内容是all),试着去掉all在编译则会通过


     或者在Build(Incremental build)后面的variable..按钮Button中选择build_project 或者 build_files都可编译通过。


解决


在C/C++ Build中的Behavior Tab(行为or规则)标签下,看到一个Build(Incremental build)CheckBox和一个文本框(内容是all)


解决方法1: 去掉all在编译则会通过  
解决方法2: 在Build(Incremental build)后面的variable..按钮Button中选择build_project 或者 build_files都可编译通过。


解决方法3:在Build(Incremental build)后面的text(文本框中)输入 -f Makefile,可以编译通过。


总结


Build(Incremental build)意为增加编译规则(通俗易懂点就是给make增加后面的参数),默认是all,因为makefile中all标签不存在,所以会出现make: *** No rule to make target `all'.  Stop.


因此去掉all,实质make


        添加-f Makefile ,实质是make -f Makefile


        在variable..按钮按钮Button中选择build_project 或者 build_files,实质是make -f Makefile
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值