开始学习 qt creator 了, 今天在 linux 和 windows 上都装了一遍, 在 linux 下可以正常编译执行自己的程序, 在 windows 下遇上了点问题, 在执行程序的时候,提示 “找不到 mingwm10.dll” , 解决方法, 要静态编译Qt的库。
步骤:
1 首先在开始菜单打来 Qt Command Prompt ,
2 执行命令 configure -release -static -fast
3 执行命令 mingw32-make
4 执行命令 mingw32-make clean
以上步骤是编译qt静态库的过程,摘自网友lsyer的博客,现在在Qt\2009.03\qt\lib 目录下,会生成一些后缀名为.a的静态库文件, 接下来再次编译自己的应用程序, 这时报错,错误信息提示找不到 QtGuid 和 QtCored,这时把Qt\2009.03\qt\lib目录下对应的libQtGuid4.a 和 libQtCored4.a改为libQtGuid.a 和 libQtCored.a 也可以另复制出一份,再改名。
接下来,编译自己的应用程序通过, 但执行应用程序hello.exe的时候,依然提示找不到qt的库,后来发现编译的是debug版本,只要打开左边的Projects栏,勾选里面的 Release,再次编译,就会在Release目录下生成可执行文件,现在只要把C:\Qt\2009.03\mingw\bin目录下的 mingwm10.dll拷贝到Release目录下和可执行程序放在一起,现在程序就可以正常执行了,不会再提示找不到qt的库了。
1. 修改配置文件(1) Qt creator
Qt 4.3 and newer
Edit <QTDIR>\mkspecs\win32-g++\qmake.conf:
Change
QMAKE_LFLAGS = -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
to (add -static)
QMAKE_LFLAGS = -static -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
See Trolltech's knowledgebase: Why does a statically built Qt use the dynamic Visual Studio runtime libraries? Do I need to deploy those with my application?
Applications built with MSVC depend on msvc*.dll. Following changes must be done to mkspecs in order to eliminate this dependency.
Edit <QTDIR>\mkspecs\win32-X\qmake.conf, where 'X' stands for the version of Visual Studio: