QT安装编译问题

      QT用了很长时间了,直到最近才发现对QT的安装编译了解甚微。先前用的qt4.4.1是根据一个文档亦步亦趋的安装完成,之后就一直使用,并没有关心不同安装配置的差异。特别地,我在之前的机子上为VS2005编译的4.4.1版本在我更换机器后为省事直接把编译好的包拷贝到新机器上也能用,但是总是有些不对的地方,更神奇的是,我用VS2003.net开发的时候竟然在相当长的时间内没出问题。但问题总是有的,而且终于发现了。由于近来一直使用VS2003.NET,在使用一个QImage图像类的时候发现其函数调用总不成功,QImage::load()也返回false.我先还未以为是编译的QT包问题,在网上搜索了半天,没有找到类似或者找到类似但其实不是同一个问题的问题。然后尝试QPixmap,QBitmap,QPicture,全部load失败,苦思了一下午不得其解,而该程序传至其他机器(正常编译QT)上却能正常运行。最后,才想到版本不对的问题。其一是我的QT包是直接拷贝而来,这其中是不是还关联着一些问题不得而知;其二是原来编译的这个QT版本是VC2005的,显然在VS2003.NET上使用可能会出问题。(奇怪的是我怎么能用了这么长时间)因此我决心花上几个小时重新编译,在花了一整个晚上的时间里,我重新为VS2005和VS2003.NET重新分别编译了一次。天啊终于正常了。在如何编译QT版本的问题上,我在网上也搜索了一下,结合我以前编译的过程也简单的说一下:

      首先以我正在用的QT4.1.1版本在VS2005下编译安装为例,解压代码至某个文件夹:假如为D:/Qt/4.4.1-msvc2005.目录之间不要空格,传说后来编译可能有问题.

      >>设置环境变量:环境变量PATH里面添加“D:/Qt/4.4.1-msvc2005/bin”

                                添加新的环境变量QMAKESPEC,值为"win32-msvc2005"

                                添加新的环境变量QTDIR,值为"D:/Qt/4.4.1-msvc2005"

      >>在"Microsoft Visual Studio 2005" -> "Visual Studio Tools", 运行命令行:D:/Qt/4.4.1-msvc2005>configure -no-dsp -vcproj

      >>编译过程中会问是否接受GPL协议,选"y";一段时间后,qmake被编译出来,简单敲入namke即可继续,数个小时后编译完成。

      >>安装VS2005插件,Qt Visual Studio Integration

      >>配置Visual Studio 2005,"Tools" -> "Options" -> "Qt" -> "Builds"添加项:名字为"Qt 4.4.1", 路径为"D:/Qt/4.4.0-msvc2005".

      >>工具->选项->项目和解决方案->VC++目录,在包含文件一栏添加D:/Qt/4.4.1-msvc2005/include,库文件一栏添加D:/Qt/4.4.1-msvc2005/lib

      特别的,为不同的开发环境安装QT的时候,环境变量QMAKESPEC的值是不同的,比如VS2005是win32-msvc2005,6.0 使用win32-msvc,, VS2003使用win32-msvc.net, 2008就是 win32-msvc2008.

      以下是网上搜索的configure命令的具体参数:(转自http://blog.163.com/lijiji_1515/blog/static/12687744620098501235626/)

   -release ........... 调试关闭.没有调试库,自己的项目只能发布,不能调试(没有调试库的缘故),如果你硬要编译debug版本的话,会提示找不到xxxxxd.dll 
 *  -debug ............. 只有调试库,没有释放库,也就是说以后自己的项目只能调试,如果你硬要编译debug版本的话,会提示找不到xxxxx.dll
 +  -debug-and-release . 编译后包含两种库。最好编译两种库
    -opensource ........ 编译开源版.
    -commercial ........ 编译商业版.  这两个参数一般不需指定,configure开始需要你选择版本。
    -developer-build ... 编译开发者选项。
 *  -shared ............动态编译.
    -static ............ 静态链接库.貌似有插件不能用静态编译。
 *  -no-fast ........... configure生成所有项目makefiles文件,并编译
    -fast .............. 只生成库目录及子目录下的项目的makefiles文件. 
    -no-exceptions ..... 关闭异常支持
 *  -exceptions ........ 开启异常支持.
    -no-accessibility .. 关闭对windows active控件支持.
 *  -accessibility .....对windows active控件支持.
    -no-stl ............ 无c++标准库支持
 *  -stl ............... 有标准库支持
尖括号在blogger出问题了。。。。。
    -no-sql- ... Disable SQL entirely, by default none are turned on.
    -qt-sql- ... Enable a SQL in the Qt Library.
    -plugin-sql-  Enable SQL as a plugin to be linked to at runtime.
                         Available values for :
                           mysql
                           psql
                           oci
                           odbc
                           tds
                           db2
 +                         sqlite
                           sqlite2
                           ibase
                         (drivers marked with a '+' have been detected as available on this system)
    -system-sqlite ..... Use sqlite from the operating system.
    -no-qt3support ..... 不提供对qt3函数支持
    -no-opengl ......... 不提供OpenGL函数支持
    -platform ... The operating system and compiler you are building on.
                         (default %QMAKESPEC%)
    -xplatform .. The operating system and compiler you are cross compiling to.
                         See the README file for a list of supported operating systems and compilers.
    -qtnamespace Wraps all Qt library code in 'namespace name {...}
    -D ........ Add an explicit define to the preprocessor.
    -I ... Add an explicit include path.
    -L ... Add an explicit library path.
    -l ... Add an explicit library name, residing in a librarypath.
    -graphicssystem Specify which graphicssystem should be used.
                          Available values for :
 *                         raster - Software rasterizer
                           opengl - Using OpenGL accelleration, experimental!
    -help, -h, -? ...... Display this information.
第三方库
    -qt-zlib ........... 使用zlib绑定到qt.
 +  -system-zlib ....... 使用操作系统的zlib
                         见 http://www.gzip.org/zlib
    -no-gif ............ 不编译gif文件读取支持插件
 +  -qt-gif ............ 编译gif文件读取支持插件
                         参见 src/plugins/imageformats/gif/qgifhandler.h
    -no-libpng ......... 不编译PNG支持插件.
    -qt-libpng ......... 编译PNG支持插件.
 +  -system-libpng ..... 使用系统libpng库
                         见 http://www.libpng.org/pub/png
    -no-libmng ......... 不编译MNG支持插件.
    -qt-libmng ......... 编译MNG支持插件.
 +  -system-libmng ..... 使用系统的mng库
                         参见 http://www.libmng.com
    -no-libtiff ........ 不编译tiff支持插件.
    -qt-libtiff ........ 编译tiff支持插件.
 +  -system-libtiff .... 使用系统的libtiff库
                         见 http://www.libtiff.org
    -no-libjpeg ........ 不编译jpeg支持插件库
    -qt-libjpeg ........ 编译jpeg支持插件库
 +  -system-libjpeg .... 使用系统的jpeg支持库
                        见 http://www.ijg.org
以下参数仅对qt for windows有效
    -no-dsp ............ 不生成 VC++ .dsp 文档.
 *  -dsp ...............生成 VC++ .dsp文档, 需要有平台标识符"win32-msvc".注意 qt4开始就不支持vc6.0了所以这两个参数无效。
    -no-vcproj ......... 不生成 VC++ .vcproj 文档
 *  -vcproj ............ 生成 VC++ .vcproj 文档, 需要平台标识符"win32-msvc.net".也就是vs2003以上的编译环境
    -no-incredibuild-xge Do not add IncrediBuild XGE distribution commands to custom build steps.
 +  -incredibuild-xge .. Add IncrediBuild XGE distribution commands to custom build steps. This will distribute MOC and UIC steps, and other custom buildsteps which are added to the INCREDIBUILD_XGE variable.
                         (The IncrediBuild distribution commands are only added to Visual Studio projects)
    -no-plugin-manifests  插件不嵌入manifests.
 *  -plugin-manifests .. 插件嵌入manifests.
    -no-qmake .......... 不编译qmake
 *  -qmake ............. 编译 qmake.   不建议 不编译qmake
    -dont-process ...... 不生成makefiles和project文档. 比 -no-fast 参数优先级更高
 *  -process ........... 生成makefiles和project文档.
    -no-rtti ........... 不编译运行时类型信息。
 *  -rtti .............. 编译运行时类型信息。
//下面是对指令的支持,不解释了
    -no-mmx ............ Do not compile with use of MMX instructions
 +  -mmx ............... Compile with use of MMX instructions
    -no-3dnow .......... Do not compile
with use of 3DNOW instructions
 +  -3dnow ............. Compile with use of 3DNOW instructions
    -no-sse ............ Do not compile with use of SSE instructions
 +  -sse ............... Compile with use of SSE instructions
    -no-sse2 ........... Do not compile with use of SSE2 instructions
 +  -sse2 .............. Compile with use of SSE2 instructions
 +  -direct3d ..........  将Direct3D支持编译进来。检测不到direct3d sdk 就不支持
    -no-openssl ........ Do not compile in OpenSSL support
 +  -openssl ........... Compile in run-time OpenSSL support
    -openssl-linked .... Compile in linked OpenSSL support
    -no-dbus ........... Do not compile in D-Bus support
 +  -dbus .............. Compile in D-Bus support and load libdbus-1 dynamically
    -dbus-linked ....... Compile in D-Bus support and link to libdbus-1
    -no-phonon ......... 不将 Phonon 模块 编译进来
 +  -phonon ............ 将 Phonon 模块编译进来  (若使用的规范的c++编译器则会自动编译Phonon模块)
    -no-phonon-backend . Do not compile the platform-specific Phonon backend-plu
gin
 *  -phonon-backend .... Compile in the platform-specific Phonon backend-plugin
    -no-webkit ......... 不将webkit模块编译进来,编译webkit非常耗时间。
 +  -webkit ............ 将webkit模块编译进来 (若使用的规范的c++编译器则会自动编译WebKit模块)
    -no-scripttools .... Do not build the QtScriptTools module.
 *  -scripttools ....... Build the QtScriptTools module.
    -arch ....... 外观样式.
                        有以下几种 :
 *                         windows
                           windowsce
                           boundschecker
                           generic
    -no-style-尖括号里包含上面的样式。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值