qt5 编译一些问题 还有打包的dll依赖

来源:互联网 发布:北京医科大网络教育 编辑:程序博客网 时间:2024/05/13 19:35

今天尝试了一下用命令行直接编译qt qmake可以用来设置参数生成pro文件,但如果你使用creator作用的,已经有了那么直接qmake这个pro文件生成makefile就可以了,参数直接help查看就好了。 然后下来有了makefile就直接nmake就可以解决,这里是用的vs2010编译。然后编译中出了很多问题。这里列一下方便搜索的。。

比如:

'rc' 不是内部或外部命令,也不是可运行的程序 或批处理文件。

或者   #include "winver.h"失败   之类的。总之一个加一个

于是乎一直在加环境变量...后来才发现其实在下面路径会有一个:

"C:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT"
"C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"

"C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"

里面其实就是帮你在编译运行之前配置好这些环境变量,然后编译就没问题了..不然很多问题还是很麻烦的。。一个一个解决。当然对照这个文件也能去设置好自己的环境变量。

然后编译出来还有一个打包的问题,本来是自己利用一个dependency walker去看dll然后去qt的目录下自己啦dll过来,然后和release出来的可执行文件单独拿出来就可以运行了。 但是就忘了去看文档什么的。。 到一些环境下就出问题了。。其实http://qt-project.org/doc/qt-5/windows-deployment.html说的很清楚的了。。。

When looking at the release build of the Plug & Paint executable (plugandpaint.exe) with the dependstool, the tool lists the following immediate dependencies to non-system libraries:

QtVC++ 8.0 (2005)VC++ 9.0 (2008)VC++ 10.0 (2010)MinGW
  • QT5CORE.DLL - TheQtCore runtime
  • QT5GUI.DLL - TheQtGui runtime
  • QT5WIDGETS.DLL - TheQtWidgets runtime
  • MSVCR80.DLL - The C runtime
  • MSVCP80.DLL - The C++ runtime
  • MSVCR90.DLL - The C runtime
  • MSVCP90.DLL - The C++ runtime
  • MSVCR100.DLL - The C runtime
  • MSVCP100.DLL - The C++ runtime
  • MINGWM10.DLL - TheMinGW run-time
  • LIBGCC_S_DW2-1.DLL
  • LIBSTDC++-6.dll
所以这里有两个dll需要你去拿过来。然后其实qt有帮你实现依赖dll获取的工具了 也在上面这个文档的后面

The Windows Deployment Tool

The Windows deployment tool can be found in QTDIR/bin/windeployqt. It is designed to automate the process of creating a deployable folder that contains all libraries, QML imports, plugins, translations that are required to run the application from that folder. This is used to create the sandbox for Windows Runtime or an installation tree for Windows desktop applications that can be easily bundled by an installer.

就是这个windeployqt ,直接利用,参数加上你的可执行文件,就会帮你把需要的dll都打包给你,放在当前的文件下,你要做的就是把上面图说过的那一两个msvc剩下的拉过来而已,然后就方便多了,直接压缩就完了如果没有更多的要求的话。
0 0