QT Creator编译和使用QT的静态库
2011-04-19 14:02
267 查看
开始学习 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
(2). Visual Studio
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:
步骤:
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
(2). Visual Studio
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:
相关文章推荐
- QT Creator编译和使用QT的静态库
- 使用Qt(mingw)编译FreeType为 .a 静态库
- QT5 下静态库的编译和使用(转载)
- QT小知识点(3) -Qt Creator 使用技巧之提高编译速度【使用jom参数】
- Qt:使用Qt creator (32bit)编译Qt creator(64bit)
- 使用VS2012编译QT 5.2.1静态库
- VS2015 Qt5.9环境下QtFtp静态库编译及使用
- 使用Vs2005 VS2008编译真正的静态Qt程序
- VC动态库,静态库编译选项的使用
- 编译arm_qt-4.5_build出错与Linux vi的使用
- 使用VC2005编译“真正”的静态Qt应用程序
- Qt编译和使用boost库
- QT 4.8 静态库编译方法
- vs2012编译使用lua 5.2静态库
- QT使用静态库的时需要外加库
- 使用vc9 编译Qt5.4
- QT中静态库的生成与使用
- Ubuntu下 在终端使用 qmake 编译 Qt widgets程序
- g++ 编译链接C++代码, 生成与使用静态库和动态库
- win环境下,用虚拟化工具打包Qt动态编译exe的过程(使用Enigma Virtual Box)