Eclipse C/C++ 的 Makefile在Linux中
我正在使用 Eclipse 3.6 for C/C++ for Linux。我需要用我自己的工作 makefile 编译现有项目。这个 makefile 在命令行中运行良好,但是当我将项目导入 Eclipse 并尝试使用 Build 时,它不起作用,似乎它尝试使用 Eclipse 自动创建的 makefile。我取消选中“项目属性 - C/C++ 构建”中的“自动生成 Makefile”开关,而不是出现许多错误:“*** 命令在第一个目标之前开始。停止。”
可能是这个项目没有正确导入到 Eclipse 中?我知道有一个“Standard Make project”这样的东西,它不会自动创建makefile,但需要我自己的makefile,但是在Eclipse IDE中(在File-New-C++ Project下)没有可用的“Standard Make project”选项。 那么问题是如何将 Eclipse 指向正确的 makefile 来构建导入的项目?
我还尝试在项目属性 - C/C++ Build 中关闭“使用默认构建命令”并将其放入“构建命令”行 /path_to_project_folder/make 中,结果是(在控制台中): 无法运行程序“/path_to_project_folder/make”:未知原因” 我将不胜感激任何建议。
i'm using Eclipse 3.6 for C/C++ for Linux. I need to compile existing project with my own working makefile. This makefile works well from the command line, but when I imported my project into Eclipse and try to use Build, it doesn't work, seems that it try to use makefile automatically created by Eclipse. I unchecked the switch "Generate Makefile automatically" in Project Properties - C/C++ Build, and instead of many errors got this: "*** commands commence before first target. Stop."
May be this project was not imported correctly into Eclipse? I know there is such a thing as "Standard Make project" which will not create makefile automatically but needs my own makefile, but in Eclipse IDE (under File- New- C++ Project) there is no "Standard Make project" options available.
So question is how to point Eclipse to the right makefile for building the imported project?
I also tried to switch off the "Use default build command" in Project Properties - C/C++ Build and put there in "Build command" line /path_to_project_folder/make, the result is (in Console):
Cannot run program "/path_to_project_folder/make": Unknown reason"
I would appreciate any suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要进口。
相反,使用 C/C++ 下的“Makefile Project from Existing Code”创建一个新项目。
是的,这有点违反直觉,但它确实有效。
Don't import.
Instead, create a NEW project using the "Makefile Project from Existing Code" under C/C++.
Yes, it's somewhat counterintuitive, but it works.
到目前为止,我发现处理这种情况的最佳方法是用我自己的 makefile 替换由 Eclipse 自动生成的 makefile(存储在 Debug 目录中,由 Eclipse 在项目文件夹中创建),其中我只包含以下几行:
现在,当我尝试从 Eclipse IDE(使用按钮)构建项目时,它会执行该 makefile,它会完成所有工作,并且项目会正常编译。
So far the best way to deal with this situation which i found, is to substitute automatically generated by Eclipse makefile (which is stored in Debug directory, created by Eclipse in the project folder) with my own makefile, in which i just include this lines:
Now when i try to build the project from the Eclipse IDE (with the button) it executes that makefile, which does all the job, and the projects compiles normally.