将自定义 Makefile 与 Eclipse/CDT 一起使用

发布于 2024-08-14 13:38:44 字数 118 浏览 2 评论 0原文

我有一个包含多个 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

原来分手还会想你 2024-08-21 13:38:44

您可以创建自定义 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.

〗斷ホ乔殘χμё〖 2024-08-21 13:38:44

有一个选项可以从现有的 makefile 创建项目:使用“项目向导”并选择“Makefile 项目”。

There is an option to create a project from existing makefiles: use the "Project Wizard" and select "Makefile project".

伤感在游骋 2024-08-21 13:38:44

您可以在 eclipse 项目属性 -> 中禁用“自动生成 makefile” c/c++ 构建(构建器设置。)

You can disable "Generate makefiles automatically" in eclipse project properties -> c/c++ build (builder settings.)

锦欢 2024-08-21 13:38:44

在我最近尝试编译跨 ARM 编译时,我痛苦地发现了如何让它工作。

首先,我创建了一个“使用现有代码的 Makefile 项目”。我选择了Cross ARM工具链。如果我现在在 Eclipse 中打开控制台并进行 make,它就可以工作。

现在要在 GUI 中构建,我必须:

  1. 使用“生成 Makefile”将属性更改为“内部构建器”
    检查过。
  2. 设置选项现在提供“构建工件”选项卡。使用 ${Project} 选择可执行文件。
  3. 建造。这将导致链接阶段出现错误。
  4. 将设置切换为External Builder,取消选中“Automatic Makefile Generation”
  5. Clean
  6. Build

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:

  1. Change properties to Internal Builder, with Generate Makefile
    checked.
  2. The settings option now offers Build Artifact tab. pick executable with ${Project}.
  3. Build. This will result in error in link stage.
  4. Switch the settings to External Builder, uncheck "Automatic Makefile generation"
  5. Clean
  6. Build
弃爱 2024-08-21 13:38:44

您所要做的就是告诉 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 的。

以下是说明:

  1. project->properties->C/C++ Build
  2. 单击“Builder”选项卡
  3. 取消选择“Use default build command”
  4. 将命令更改为 ${CCS_UTILS_DIR}/bin/gmake -f ../sri.mk

gui 设置的屏幕截图

请注意,构建是从 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:

  1. project->properties->C/C++ Build
  2. click on the 'Builder' tab
  3. Un-select 'Use default build command"
  4. Change the command to ${CCS_UTILS_DIR}/bin/gmake -f ../sri.mk

screen capture of gui settings

Note that the build is kicked off from the Debug directory. The Debug 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.

奢欲 2024-08-21 13:38:44

此外,可能会有一行显示 "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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文