如何在不使用 QtCreator 的情况下将 dll 文件复制到 Qt 中的输出目录?

发布于 2024-11-14 07:32:27 字数 498 浏览 3 评论 0原文

我有一个基于 Qt 的应用程序,它使用许多在项目外部构建的 dll。这些 dll 被签入源代码,因为我们不会非常频繁地重建它们(它们需要几个小时才能构建,我不希望它们出现在主项目中)。我想在构建完成后将这些 dll 复制到适当的目录(发布、调试)中。有没有办法将该复制步骤合并到 .pro 文件中,以便将复制传播到使用该代码的每台计算机?我在 this 等地方找到的建议是使用 post-构建步骤并构建批处理文件,但构建后步骤不在计算机之间共享(它们存储在 .pro.user 文件中,该文件是特定于计算机的)。

我尝试过使用类似的方法:

Debug:POST_TARGETDEPS = ../../Dir1/Dir2/bin/mylib.dll

但这不会将文件复制到调试目录中,也不会复制到 DESTDIR 目录中。

I have a Qt-based application that uses a number of dlls that are built outside of the project. These dlls are checked into source because we will not be rebuilding them very frequently (they take on the order of hours to build, I don't want those to be in the main project). I want to copy those dlls into the appropriate directories (release, debug) once building has occurred. Is there a way to incorporate that copy step into the .pro file, so that the copying is propagated to each machine that uses the code? The suggestion I've found in places like this is to use a post-build step and build a batch file, but post-build steps are not shared between machines (they are stored in the .pro.user file, which is machine specific).

I've tried using something like:

Debug:POST_TARGETDEPS = ../../Dir1/Dir2/bin/mylib.dll

But that doesn't copy the file into the debug directory nor into the DESTDIR directory.

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

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

发布评论

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

评论(1

穿透光 2024-11-21 07:32:27

您将需要使用 INSTALLS 关键字,然后确保在构建时执行 make install

dlls_to_move.path = $DESTDIR
dlls_to_move.files += ../../Dir1/Dir2/bin/mylib.dll
INSTALLS += dlls_to_move

您可以在QMake 文档中找到有关安装的更多信息。

You will want to use the INSTALLS keyword and then make sure when you build you do a make install.

dlls_to_move.path = $DESTDIR
dlls_to_move.files += ../../Dir1/Dir2/bin/mylib.dll
INSTALLS += dlls_to_move

You can find more information on INSTALLS in the QMake documentation.

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