将自定义 Makefile 与 Eclipse/CDT 一起使用
我有一个包含多个 .c
和 .h
文件的项目,我编写了自己的 makefile。
如何配置 Eclipse 以使用原始位置的 makefile 和源文件?
I have a project of multiple .c
and .h
files and I write my own makefile.
How can I configure Eclipse to use my makefile and my source files from their original locations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以创建自定义 Makefile 并确保它位于项目根目录中。然后您需要禁用自动生成的 makefile。您可以通过转到此处来做到这一点:
项目属性(右键单击项目并选择属性)-> C/C++ 构建 ->在该窗口中取消选中“自动生成 Makefiles”。
要使用您自己的目标,您可以打开名为“Make Target”的视图:
Window ->显示视图-> Make Target
在该视图中,您可以创建一个新目标,该目标将使用自定义 Makefile 中的相应目标。
You can create a custom Makefile and make sure it's in your project root. Then you need to disable the auto generated makefiles. You can do that by going here:
Project Properties (right click on project and select properties) -> C/C++ Build -> in that window uncheck "Generate Makefiles Automatically."
To use your own targets you can open the View called "Make Target":
Window -> Show View -> Make Target
In that view you can create a new target that will use the corresponding target in your custom Makefile.
有一个选项可以从现有的 makefile 创建项目:使用“项目向导”并选择“Makefile 项目”。
There is an option to create a project from existing makefiles: use the "Project Wizard" and select "Makefile project".
您可以在 eclipse 项目属性 -> 中禁用“自动生成 makefile” c/c++ 构建(构建器设置。)
You can disable "Generate makefiles automatically" in eclipse project properties -> c/c++ build (builder settings.)
在我最近尝试编译跨 ARM 编译时,我痛苦地发现了如何让它工作。
首先,我创建了一个“使用现有代码的 Makefile 项目”。我选择了Cross ARM工具链。如果我现在在 Eclipse 中打开控制台并进行 make,它就可以工作。
现在要在 GUI 中构建,我必须:
检查过。
In my latest attempt to compile a Cross ARM compile, I made a painful discovery on how to get this working.
First I created a "Makefile project with existing Code". I selected the Cross ARM tool chain. If I now open a console within Eclipse and make, it works.
Now to build within the GUI, I had to:
checked.
您所要做的就是告诉 gmake 使用您的 makefile。 Code Composer Studio 的默认命令是
${CCS_UTILS_DIR}/bin/gmake
。只需告诉 gmake 使用您自己的 makefile(例如sri.mk
)。我们使用 -f 选项来做到这一点。因此,默认命令将变为${CCS_UTILS_DIR}/bin/gmake -f ../sri.mk
请注意,Code Composer Studio 是基于 Eclipse 的。
以下是说明:
${CCS_UTILS_DIR}/bin/gmake -f ../sri.mk
请注意,构建是从
Debug
目录启动的。Debug
目录包含由 Eclipse 生成的 makefile。我将 makefile 放在项目的顶级目录中,这就是为什么我将../
放在-f ../sri.mk
中。 。All that you have to do is tell gmake to use your makefile. The default command for Code Composer Studio is
${CCS_UTILS_DIR}/bin/gmake
. Simply tell gmake to use your own makefile (e.g.sri.mk
). We do this with the -f option. So the default command would become${CCS_UTILS_DIR}/bin/gmake -f ../sri.mk
Note that Code Composer Studio is Eclipse based.
Here are the instructions:
${CCS_UTILS_DIR}/bin/gmake -f ../sri.mk
Note that the build is kicked off from the
Debug
directory. TheDebug
directory contains the makefiles that are generated by Eclipse. I put my makefile in the top level directory of the project so that's why I put../
in-f ../sri.mk
.此外,可能会有一行显示
"default: esh $(PLUGIN_SO),"
或类似的内容,具体取决于您的项目。我发现将"default"
更改为"all"
也将使项目能够编译。这是一个方便的功能,eclipse:)Also, there might be a line that says
"default: esh $(PLUGIN_SO),"
or something along those lines depending on your project. I've found that changing the"default"
to"all"
will enable the project to compile too. This is a handy feature, eclipse :)