让 Eclipse CDT 在生成的 Makefile 中使用相对包含路径
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有一个更好的方法来做到这一点:“项目>属性>C/C++构建>设置>工具设置>跨G++[或GCC]编译器>包含”。单击加号按钮,然后写入:
此方法允许您通过项目文件夹的相对路径指定任何外部文件夹,即使它位于父子文件夹中。
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:
This approach allows you to specify any external folder by relative path to your project folder, even if it is located in parent subfolders.
如果您在“包含路径”中使用相对路径(而不是
${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.您在“项目 > 属性 > 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.
我发现这个问题很久以前就被问过。我正在尝试使用 Eclipse CDT 设置 GitLab CI,建议的最简单方法是使用 CDT 生成的现有 makefile。但是,我无法轻松配置 Eclipse CDT 以使用相对路径轻松在项目中生成 makefile,我可以看到我可以更改“include”设置,但是 makefile 中使用 make 中的绝对路径引用了其他文件文件也是如此。所以我只是使用 PowerShell 脚本将所有绝对路径更新为相对路径。检查 PWD 的绝对路径,然后计算 ../ 以返回到项目的根目录。我的有 5 个文件夹深。
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.