Eclipse CDT 没有在头文件更改时构建项目

时间:2023-04-19
本文介绍了Eclipse CDT 没有在头文件更改时构建项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我有 Eclipse Platform 3.7.2 和 CDT 8.0.2.

当我想做全部构建"时,来自其他工作区项目的标头不计为依赖项,并且不会重新构建任何内容.

我有一个 hello world 应用程序和一个静态库项目.静态库在项目属性 -> c/c++ 常规 -> 路径和符号 -> 引用选项卡 -> 选中活动"中设置为参考.这是我唯一更改的设置.

顺便说一句,为什么 Eclipse 在项目属性下有一个额外的项目引用"顶级项,这完全让我感到惊讶.

无论如何,我尝试了外部构建器(在项目创建时默认选择)和内部构建器,还结合了全局设置首选项 -> c++ -> 构建 -> 仅在存在时构建配置"Eclipse 资源变化......'

感谢您对此的任何想法.

更新:这是构建依赖项目 Proj2 时的控制台输出(Proj1 是 lib).'make all' 被调用,但它只是重新链接,它不会重新编译 Main.cpp.有熟悉 eclipse 生成的 makefile 的人吗?再次感谢.

**** 为项目 Proj2 构建配置调试 ****做所有构建目标:Proj2调用:Cross G++ Linkerg++ -L"/home/user/.eclipse-workspace/Proj1/Debug" -o "Proj2" ./Main.o -lProj1完成的建筑目标:Proj2****构建完成****

这已经有 1.5 年的历史了,想补充一下,已经为此提交了一个 Eclipse 错误:https://bugs.eclipse.org/bugs/show_bug.cgi?id=375800

解决方案

这个问题存在一个bug:https://bugs.eclipse.org/bugs/show_bug.cgi?id=375800

还有一个可行且简洁的解决方法(原始请求者已经知道这一点).所以我只是交叉链接到实际答案:) https://bugs.eclipse.org/bugs/show_bug.cgi?id=375800#c11

Krzysztof Czaińsk 的所有作品

在您的项目 c 或 c++ 编译器设置中,在标志之后添加 -MT ${OUTPUT_PREFIX}${OUTPUT}:

<块引用>

${COMMAND} ${FLAGS} -MT ${OUTPUT_PREFIX}${OUTPUT} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}

这将创建正确的 .d 文件

<小时>

补充:解决方法有一个副作用.在一个干净的 make all 之后总是运行两次,然后才说什么都不做.仍然比更改后不编译要好;-)

I have Eclipse Platform 3.7.2 and CDT 8.0.2.

When I want to do 'Build All' headers from other workspace projects are not counted as dependencies, and nothing is rebuilt.

I have a hello world application and a static library project. The static library is set as a reference in Project Properties -> c/c++ general -> Paths and SYmbols -> References tab -> checked 'Active'. That's the only setting I changed.

By the way, It totally beats me why Eclipse has an additional "Project References" top-level item under Project Properties.

Anyway, I tried both the External Builder (which gets selected by default on project creation) and the INternal Builder, also coupled with combinations of the global setting 'Preferences -> c++ -> Build -> Build configurations only when there are Eclipse resource changes........'

Thanks for any thoughts on this.

Update: This is the console output when building dependent project Proj2 (Proj1 is the lib). 'make all' is called but it merely re-links, it doesn't recompile Main.cpp as it should. Anyone out there familiar with eclipse-generated makefiles? Thanks again.

**** Build of configuration Debug for project Proj2 ****

make all 
Building target: Proj2
Invoking: Cross G++ Linker
g++ -L"/home/user/.eclipse-workspace/Proj1/Debug" -o "Proj2"  ./Main.o   -lProj1
Finished building target: Proj2


**** Build Finished ****

Edit: This is 1.5 years old already, wanted to add that an Eclipse bug had been filed for this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=375800

解决方案

there exists a bug for this issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=375800

And a working and neat workaround (The orignal requester knows this already). So I just crosslink to the actual answer :) https://bugs.eclipse.org/bugs/show_bug.cgi?id=375800#c11

All credits to Krzysztof Czaińsk

In your project c or c++ compiler settings add -MT ${OUTPUT_PREFIX}${OUTPUT} after the flags:

${COMMAND} ${FLAGS} -MT ${OUTPUT_PREFIX}${OUTPUT} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}

This will create the correct .d-files


Addition: The workaround has one side-effect. After a clean make all always runs twice before it says nothing to do. Still better than not compiling after a change ;-)

这篇关于Eclipse CDT 没有在头文件更改时构建项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:Eclipse C++ 包括来自我的源文件夹的头文件 下一篇:jax-ws 将 Content-type 更改为 Content-Type 因为服务器是

相关文章

最新文章