简体   繁体   English

如何在 Eclipse 中使用外部 makefile

[英]How to use external makefile in Eclipse

I have a source code of an OpenSource project which I get from SVN.我有一个来自 SVN 的 OpenSource 项目的源代码。 I was able to run autogen --> configure --> and make successfully (through the terminal).我能够运行 autogen --> configure --> 并成功(通过终端)。 But I want to build the same project with Eclipse, and I can't port manually those source files to eclipse though.但是我想用 Eclipse 构建相同的项目,但我无法手动将这些源文件移植到 Eclipse。 So, How can I set Eclipse to use external make files ?那么,如何将 Eclipse 设置为使用外部 make 文件? can anyone please help me ?谁能帮帮我吗 ? Thanks.谢谢。

Ok, I got it, It was straightforward.好的,我明白了,这很简单。 Just go to project properties --> C/C++ Build --> Make file generation --> and untick "Generate Make files automatically".只需转到项目属性 --> C/C++ 构建 --> 生成文件 --> 并取消选中“自动生成生成文件”。 In additionally you may have to set the Build location also.此外,您可能还必须设置构建位置。

This might vary with different versions.这可能因不同版本而异。 The one I use is Eclipse 3.5 with CDT 6, and it is quite straightforward:我使用的是带有 CDT 6 的 Eclipse 3.5,它非常简单:

New Project -> C++ Project -> Makefile Project -> Empty project新建项目 -> C++ 项目 -> Makefile 项目 -> 空项目

Untick the 'Use default location' and provide the location where the root of your project and Makefile reside.取消勾选“使用默认位置”并提供项目根目录和 Makefile 所在的位置。

I found it misleading at first, and had a couple of dry runs in copied directories to make sure that the 'Empty project' would not clear the Makefile, but the fact is that the option name is probably misleading as 'Empty' stands for CDT will not create a Makefile for you (but won't delete an existing version either)起初我发现它具有误导性,并在复制的目录中进行了几次试运行以确保“空项目”不会清除 Makefile,但事实是选项名称可能具有误导性,因为“空”代表CDT不会为您创建 Makefile(但也不会删除现有版本)

You may be able to avoid creating a custom makefile.您可以避免创建自定义生成文件。 The standard Eclipse autogenerated makefile has a couple of hooks:标准的 Eclipse 自动生成的 makefile 有几个钩子:

.
.
-include ../makefile.init
.
.
.
-include ../makefile.init
.
.

That allow you to add your own tweaks to the build process whilst retaining Eclipse's build automation.这允许您将自己的调整添加到构建过程,同时保留 Eclipse 的构建自动化。

As an example, I have need to include a binary image in my executable so I have a makefile.defs with:例如,我需要在我的可执行文件中包含一个二进制图像,所以我有一个 makefile.defs :

binaryblob.o:
    ld -r -b binary -o binaryblob.o ../binaryblob.mid

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM