如何在不使用 QtCreator 的情况下将 dll 文件复制到 Qt 中的输出目录?
我有一个基于 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要使用
INSTALLS
关键字,然后确保在构建时执行make install
。您可以在QMake 文档中找到有关安装的更多信息。
You will want to use the
INSTALLS
keyword and then make sure when you build you do amake install
.You can find more information on INSTALLS in the QMake documentation.