让 Eclipse CDT 在生成的 Makefile 中使用相对包含路径

发布于 2024-09-28 14:41:40 字数 241 浏览 1 评论 0原文

我正在使用 Eclipse CDT。我已经配置了“外部生成器”,并且自动生成 Makefile。不幸的是,生成的 Makefile 包含绝对包含路径。我想在其他系统(未安装 Eclipse)上使用生成的 Makefile - 有没有办法让 Eclipse 使用 Makefile 的相对路径?

我已经在“设置”->“设置”下配置了我的项目包含目录工具设置-> GCC C 编译器 ->使用 ${workspace_log} 包含路径。

I am using the Eclipse CDT. I have configured the "external Builder" and I am generating the Makefiles automatically. Unfortunately, the generated Makefiles contain the absolute include path. I would like to use the generated Makefiles on other systems (where Eclipse is not installed) - is there a way to make Eclipse use relative paths into the Makefile?

I have configured my projects include directory under Settings -> Tool Settings -> GCC C Compiler -> Include Paths using ${workspace_log}.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

西瓜 2024-10-05 14:41:40

有一个更好的方法来做到这一点:“项目>属性>C/C++构建>设置>工具设置>跨G++[或GCC]编译器>包含”。单击加号按钮,然后写入:

“${ProjDirPath}/../../../somefolder1/somefolder2”

此方法允许您通过项目文件夹的相对路径指定任何外部文件夹,即使它位于父子文件夹中。

There is a better way to do this: "Project > Properties > C/C++ Build > Settings > Tool Settings > Cross G++ [or GCC] Compiler > Includes". Click plus button, then write:

"${ProjDirPath}/../../../somefolder1/somefolder2"

This approach allows you to specify any external folder by relative path to your project folder, even if it is located in parent subfolders.

把时间冻结 2024-10-05 14:41:40

如果您在“包含路径”中使用相对路径(而不是 ${workspace_loc}),则 makefile(及其使用的 .mk 文件)也将包含相对路径。

If you use relative path in the 'include paths' (instead of ${workspace_loc}), then the makefile (and .mk files it uses) will include relative paths as well.

小清晰的声音 2024-10-05 14:41:40

您在“项目 > 属性 > C/C++ 常规 > 路径和符号 > 包含”选项卡中添加的相对路径是相对于您的项目文件夹的。

出现在生成的 makefile 中的内容与主 Makefile 位置相关。

The relative paths you add in "Project > Properties > C/C++ General > Paths and Symbols > Includes" tab are relative to your project folder.

The ones that appear in the generated makefiles are relative to the main Makefile location.

看透却不说透 2024-10-05 14:41:40

我发现这个问题很久以前就被问过。我正在尝试使用 Eclipse CDT 设置 GitLab CI,建议的最简单方法是使用 CDT 生成的现有 makefile。但是,我无法轻松配置 Eclipse CDT 以使用相对路径轻松在项目中生成 makefile,我可以看到我可以更改“include”设置,但是 makefile 中使用 make 中的绝对路径引用了其他文件文件也是如此。所以我只是使用 PowerShell 脚本将所有绝对路径更新为相对路径。检查 PWD 的绝对路径,然后计算 ../ 以返回到项目的根目录。我的有 5 个文件夹深。

ls *.mk -rec | %{ $f=$_; (gc $f.PSPath) | %{ $_ -replace "c:/absolute path", "../../../../.." } | sc $f.PSPath }

I found this question asked long time ago. I'm trying to setup GitLab CI with Eclipse CDT, the easiest way suggested is to use the existing makefile the CDT generated. But, I was unable to easily config the Eclipse CDT to generate the makefile in my project with relative path easily, I can see I can get "include" settings changed, but there are other files referenced in the makefile using absolute path in the make files too. So I just used a PowerShell script to update all the absolute path into relative path. Check the PWD for the absolute path, then count the ../ to back out to the root of the project. Mine was 5 folder deep.

ls *.mk -rec | %{ $f=$_; (gc $f.PSPath) | %{ $_ -replace "c:/absolute path", "../../../../.." } | sc $f.PSPath }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文