在Qt Creator中自动重建依赖关系 [英] Automatically rebuild dependencies in Qt Creator

查看:113
本文介绍了在Qt Creator中自动重建依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Qt Creator(4.6.1)让我发疯.我的应用程序分为三个部分:

Qt Creator (4.6.1) is driving me nuts. My application is split into 3 parts:

  • 该应用
  • 图书馆
  • 单元测试应用

当我在库中更改文件并重建应用程序时,编译器不会重新编译该库,而是与该库的旧版本链接.

When I change a file within the library and rebuild the application, the compiler does not recompile the library but links with the old version of the library.

此外,当我更改库,重新编译它然后编译应用程序时,因为它使用了缓存的应用程序,所以没有编译发生.

Also, when I change the library, recompile it and then compile the app, no compilation takes place because it uses the cached app.

是否可以更改设置?这是我的项目文件:

Is there a setting to change that? Here's my project file:

TEMPLATE = subdirs

SUBDIRS += \
    app \
    lib_mylib \
    tests

app.depends = lib_mylib
tests.depends = lib_mylib

该库是作为静态库构建的:

The lib is built as a static library:

TEMPLATE = lib
TARGET = mylib
CONFIG += staticlib

推荐答案

我使用CONFIG + =有序,DEPENDPATH和PRE_TARGETDEPS来解决相同的问题.它适用于Linux和MSVC.试试吧.

I have used CONFIG += ordered, DEPENDPATH and PRE_TARGETDEPS to get rid of the same problems. It works for me on linux and on win with MSVC. Try it.

在您的项目专业文件中添加:

in your project pro file add:

CONFIG += ordered

P.S .:您的lib应该列在第一位.喜欢:

P.S.: your lib should be listed first. Like :

SUBDIRS += \
    lib \
    app \
    tests

在您的exe .pro文件中,使用正确的路径添加它:

in your exe .pro file add this with correct paths:

DEPENDPATH += $$PWD/../lib
PRE_TARGETDEPS += $$OUT_PWD/../lib/liblib.a

此处找到更多选项和标志

More options and flags is to be found here

这篇关于在Qt Creator中自动重建依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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