使用Eclipse CDT自定义Makefile

时间:2014-10-12 21:42:20

标签: eclipse build makefile eclipse-cdt

我有一个带有3个.hpp文件和1个.cpp文件的C ++项目,以及一个自定义Makefile。这个项目的代码和Makefile已经存在,所以我在Project Explorer中右键单击,并将 Import->现有代码作为Makefile项目我命名了我的项目并将位置指向了根目录包含我所有文件的项目。我选择MinGW GCC作为我的工具链,因为那是我的编译器。然后我去项目 - >属性 - > C / C ++构建并取消选中自动生成Makefile

然后我通过选择文件系统并导航到包含我所有文件的项目的根目录来更改构建目录。 Build目录是 C:\ Users \ Ryan \ Desktop \ School \ CSE \ CSE 100 \ pa1-rbridges

然后我将构建命令更改为 make -f C:\ Users \ Ryan \ Desktop \ School \ CSE \ CSE 100 \ pa1-rbridges \ Makefile bst 其中 bst 是我的Makefile中的目标,我的Makefile位于该位置。当我单击工具栏上的锤子来构建我的项目时,没有任何反应。当我尝试运行我的项目时,我得到启动失败:找不到二进制文件。

我只是想让我的项目使用我的Makefile并正确构建。 我已经搜索了谷歌和堆栈溢出数小时试图弄清楚如何使这个工作,并没有运气。任何帮助表示赞赏。

2 个答案:

答案 0 :(得分:0)

解决这些问题通常始于打破它们。

首先尝试从命令行构建构建。 " make -f ..."从命令行工作?

这可能是MinGW无法正常工作的问题。

就eclipse而言,听起来你已经完成了所有事情。您可以在eclipse控制台窗口中找到线索。

答案 1 :(得分:0)

Too late for giving an answer. But this is for the other people who end up here.

You need to create a new run configuration in Run->Run Configuration... for your project, and then type a name for the output binary file like Debug\name.exe in 'C/C++ Application' box. The name must be the same as the project name.