为什么源的变化并不一定反映在机code编译后重建时的作品? [英] Why are changes in source not always reflected in machine code after build while rebuild works?

查看:141
本文介绍了为什么源的变化并不一定反映在机code编译后重建时的作品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候当我改变code在我的Qt项目(Qt Creator的2.1.0与mingw32的),这些变化没有得到建立后反映在生产机器code。出现这种情况主要是当我改变的事情就像在构造函数或默认值的方法/构造函数参数的顺序。通常情况下,完全重建修复程序(但需要几分钟)。

Sometimes when I change code in my Qt project (Qt Creator 2.1.0 with mingw32), the changes don't get reflected in the produced machine code after building it. This happens mostly when I change things like default values in constructors or the order of parameters in methods/constructors. Usually, a full rebuild fixes that (but takes a few minutes).

我被建设,这似乎有助于大部分时间之前删除生成的可执行文件或图书馆的帮助自己。这是否有件事是平均脚麻链接的目标文件时?

I'm helping myself by deleting the generated executables or librarys before building, which seems to help most of the time. Does that mean that theres something going wrong when linking the object files?

我从Java / .NET来了,我已经习惯了一个不同的行为。我会很高兴,如果有人可以解释我什么,我做错了和/或点我一些相关的文章。

I'm coming from java/.net and I'm used to a different behaviour. I'd be happy if anyone could explain me what I'm doing wrong and/or point me to some related articles.

感谢您!

推荐答案

一般情况下,在头一个变化之后,所有的源文件包括头应该被重建。
不过,qmake的是在这方面有点奇特,你需要设置为DEPENDPATH包括比当前目录中的其他文件夹。例如,如果你有

Usually, after a change in a header, all source files including that header should be rebuilt. However, qmake is a bit peculiar in this regard, you need to set DEPENDPATH for include folders other than the current directory. E.g., if you have

INCLUDEPATH += somepath_in_my_project

也添加

DEPENDPATH += some_path_in_my_project

只有DEPENDPATH,由文件的.pro内置文件被重建如果some_path_in_my_project改变一些头(如果包括头)!

Only with DEPENDPATH, files built by the .pro files are rebuilt if some header in some_path_in_my_project changes (if they include that header)!

我建议添加每个INCLUDEPATH线相同的DEPENDPATH行,除非你有一些系统目录下,你不要指望改变。

I suggest to add for each INCLUDEPATH line an identical DEPENDPATH line, unless you include some system directory you don't expect to change.

编辑:

与qmake的静态链接时也存在类似的问题:如果静态库foo.a变化,联反对它的二进制文件不重新连接。这是在QMAKE,不产生依赖性正确的错误。

A similar problem exists when linking statically with qmake: If the static lib foo.a changes, binaries linking against it are not relinked. That's a bug in QMake, not generating the correct dependencies.

一个解决方法,我发现在以前的项目:

A workaround I found in a former project:

static:unix:TARGETDEPS += path_to_my/somestaticlib.a
static:win32:TARGETDEPS += path_to_my/somestaticlib.lib

修改编辑:

由于一段时间(QT 5),上述code应该使用,而不是TARGETDEPS POST_TARGETDEPS。

Since some time (Qt 5?), above code should use POST_TARGETDEPS instead of TARGETDEPS.

这篇关于为什么源的变化并不一定反映在机code编译后重建时的作品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆