如何在Qt中为qmake指定库文件依赖?

发布于 2024-07-17 13:00:27 字数 248 浏览 3 评论 0原文

有一个 SomeLib.pro 文件,其中包含:

CONFIG  += debug
TEMPLATE = lib
TARGET = SomeLib
..

然后在依赖的 SomeApp.pro 中:

..
debug:LIBS += -lSomeLib_debug
..

如果我在 qmake 中触及 SomeLib,如何强制构建 SomeApp?

Have a SomeLib.pro file that contains:

CONFIG  += debug
TEMPLATE = lib
TARGET = SomeLib
..

Then in a dependent SomeApp.pro:

..
debug:LIBS += -lSomeLib_debug
..

How can I force SomeApp to build if I touched SomeLib in qmake?

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

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

发布评论

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

评论(6

情话墙 2024-07-24 13:00:27

它很丑陋,因为您需要给出确切的库文件名,但这应该可以工作:

TARGETDEPS += libfoo.a

It's ugly because you need to give the exact library file name, but this should work:

TARGETDEPS += libfoo.a

若水微香 2024-07-24 13:00:27

如果您在应包含该库的项目的上下文菜单中单击“添加库...”,QT Creator 将完成这项工作。

这些变量会自动为您配置:

  • LIBS
  • INCLUDEPATH
  • DEPENDPATH
  • PRE_TARGETDEPS

另请参阅 http://doc.qt.digia.com/qtcreator-2.1/creator-project-qmake-libraries.html

QT Creator will do the work if you click "Add library..." in the context menu of the project that should include the library.

These variables are configured automatically for you:

  • LIBS
  • INCLUDEPATH
  • DEPENDPATH
  • PRE_TARGETDEPS

See also http://doc.qt.digia.com/qtcreator-2.1/creator-project-qmake-libraries.html

堇色安年 2024-07-24 13:00:27

在回复 Zahir 的评论时,也许值得指出的是,如果使用 DLL,则在 qmake 文件中声明这种依赖关系是不必要的,但如果您的 exe 依赖于静态库,则必不可少

In reply to Zahir's comment, it's perhaps worth pointing out that stating this dependency in qmake files is unnecessary if using DLLs, but is essential if your exe depends on a static library.

一腔孤↑勇 2024-07-24 13:00:27

qmake 不提供这种能力。

相反,请将您的应用程序和 lib 放在子目录中,然后在其父目录中创建一个 Makefile,如下所示:

all: FRC
    cd Somelib && qmake && $(MAKE) 
    cd SomeApp && qmake && $(MAKE)

FRC:

然后始终从此目录运行 make

qmake does not provide this ability.

Instead, put your app and lib in subdirectories, then create a Makefile in their parent directory that looks something like this:

all: FRC
    cd Somelib && qmake && $(MAKE) 
    cd SomeApp && qmake && $(MAKE)

FRC:

Then always run make from this directory.

橪书 2024-07-24 13:00:27

我使用:

POST_TARGETDEPS += c:/open-en/lib/win32mingw/libosal_based.a

它可以工作,但很笨拙,因为必须指定库的完整路径,这对于每个操作系统/编译器来说都是不同的。

I used:

POST_TARGETDEPS += c:/open-en/lib/win32mingw/libosal_based.a

It works, but is clumsy since it is necessary specify full path to library, which is different for every operating system/compiler.

若言繁花未落 2024-07-24 13:00:27

当然这是不可能的,您正在谈论使用 qmake 进行反向依赖项查找? 那么您想要的是在对库 A 进行更改后构建应用程序 B(以及依赖于库 A 的任何其他应用程序)?

这有点像说如果 vbrun300.dll 更新则重新编译所有 Visual Basic 应用程序?

surely that can't be possible, you are talking about using qmake to do a reverse dependency lookup? so what u want is for it to build app B (and any other app dependent on library A) after you've made a change to library A?

that's a bit like saying recompile all visual basic apps if vbrun300.dll is updated?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文