QT4.8.1 + VS2008

来源:互联网 发布:淘宝卖家如何登录 编辑:程序博客网 时间:2024/05/21 11:00

最近经常做政府相关的项目经常用vs2008,因为没有用到什么C++高级特性,所以C++11完全够用了。QT做界面还是比较方便的,而且它和标准库的兼容让我不得不赞一个。
好了,说了这么多的废话,咱们开搞。
首先要搭建一下编译环境,我们先安装VS2008,这个很简单“下一步”就可以了,记住了安装2008的时候一定要安装MSDN,超级方便(当然有的函数介绍有些落伍了)。
我们是QT+vs2008混合编程,接着就要安装QT了,我们安装这个版本qt-win-opensource-4.8.1-vs2008,安装完了还不算完事,我们要编译它。既然是和vs2008一起用,我们就要用vs2008编译它:
第一,打开vs2008命令行(以下简称vcmd),记住用管理员权限。
第二,安装ActivePerl,这是一个脚本编译器,Qt的编译脚本都是用Perl写的,你不装它后面玩不转。
第三,在vcmd 环境下进入qt所在的安装目录(以下简称QTDIR),执行configure。同志们凡事都要自己动脑,不要直接就configure运行,否则坑死你。

//一般情况下啊,在Windows cmd命令后面加个/?就出来帮助了configure /? //这里面选项有很多的,我们挑选自己需要的用,比如说-fast这个就很实用,还有-static选了它以后你发布项目就不用把dll一起打包了,*号代表的是默认的意思Usage: configure [-buildkey <key>]       [-release] [-debug] [-debug-and-release] [-shared] [-static]       [-no-fast] [-fast] [-no-exceptions] [-exceptions]       [-no-accessibility] [-accessibility] [-no-rtti] [-rtti]       [-no-stl] [-stl] [-no-sql-<driver>] [-qt-sql-<driver>]       [-plugin-sql-<driver>] [-system-sqlite] [-arch <arch>]       [-D <define>] [-I <includepath>] [-L <librarypath>]       [-help] [-no-dsp] [-dsp] [-no-vcproj] [-vcproj]       [-no-qmake] [-qmake] [-dont-process] [-process]       [-no-style-<style>] [-qt-style-<style>] [-redo]       [-saveconfig <config>] [-loadconfig <config>]       [-qt-zlib] [-system-zlib] [-no-gif] [-no-libpng]       [-qt-libpng] [-system-libpng] [-no-libtiff] [-qt-libtiff]       [-system-libtiff] [-no-libjpeg] [-qt-libjpeg] [-system-libjpeg]       [-no-libmng] [-qt-libmng] [-system-libmng] [-no-qt3support] [-mmx]       [-no-mmx] [-3dnow] [-no-3dnow] [-sse] [-no-sse] [-sse2] [-no-sse2]       [-no-iwmmxt] [-iwmmxt] [-openssl] [-openssl-linked]       [-no-openssl] [-no-dbus] [-dbus] [-dbus-linked] [-platform <spec>]       [-qtnamespace <namespace>] [-qtlibinfix <infix>] [-no-phonon]       [-phonon] [-no-phonon-backend] [-phonon-backend]       [-no-multimedia] [-multimedia] [-no-audio-backend] [-audio-backend]       [-no-script] [-script] [-no-scripttools] [-scripttools]       [-no-webkit] [-webkit] [-webkit-debug]       [-graphicssystem raster|opengl|openvg]       [-no-directwrite] [-directwrite]Installation options: You may use these options to turn on strict plugin loading:    -buildkey <key> .... Build the Qt library and plugins using the specified                         <key>.  When the library loads plugins, it will only                         load those that have a matching <key>.Configure options: The defaults (*) are usually acceptable. A plus (+) denotes a default value that needs to be evaluated. If the evaluation succeeds, the feature is included. Here is a short explanation of each option:    -release ........... Compile and link Qt with debugging turned off. *  -debug ............. Compile and link Qt with debugging turned on. +  -debug-and-release . Compile and link two Qt libraries, with and without                         debugging turned on.    -opensource ........ Compile and link the Open-Source Edition of Qt.    -commercial ........ Compile and link the Commercial Edition of Qt.    -developer-build ... Compile and link Qt with Qt developer options                         (including auto-tests exporting) *  -shared ............ Create and use shared Qt libraries.    -static ............ Create and use static Qt libraries.    -ltcg .............. Use Link Time Code Generation. (Release builds only) *  -no-ltcg ........... Do not use Link Time Code Generation. *  -no-fast ........... Configure Qt normally by generating Makefiles for all                         project files.    -fast .............. Configure Qt quickly by generating Makefiles only for                         library and subdirectory targets.  All other Makefiles                         are created as wrappers which will in turn run qmake    -no-exceptions ..... Disable exceptions on platforms that support it. *  -exceptions ........ Enable exceptions on platforms that support it.    -no-accessibility .. Do not compile Windows Active Accessibility support. *  -accessibility ..... Compile Windows Active Accessibility support.    -no-stl ............ Do not compile STL support. *  -stl ............... Compile STL support.    -no-sql-<driver> ... Disable SQL <driver> entirely, by default none are                         turned on.    -qt-sql-<driver> ... Enable a SQL <driver> in the Qt Library.    -plugin-sql-<driver> Enable SQL <driver> as a plugin to be linked to at run                         time.                         Available values for <driver>:                           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 ..... Disables the Qt 3 support functionality.    -no-opengl ......... Disables OpenGL functionality    -opengl <api> ...... Enable OpenGL support with specified API version.                         Available values for <api>: *                         desktop - Enable support for Desktop OpenGL                           es1 - Enable support for OpenGL ES Common Profile                           es2 - Enable support for OpenGL ES 2.0 *  -no-openvg ......... Disables OpenVG functionality    -openvg ............ Enables OpenVG functionality                         Requires EGL support, typically supplied by an OpenGL                         or other graphics implementation    -platform <spec> ... The operating system and compiler you are building on.                         (default %QMAKESPEC%)    -xplatform <spec> .. The operating system and compiler you are cross                         compiling to.                         See the README file for a list of supported operating                         systems and compilers.    -qtnamespace <namespace> Wraps all Qt library code in 'namespace name {...}    -qtlibinfix <infix> Renames all Qt* libs to Qt*<infix>    -D <define> ........ Add an explicit define to the preprocessor.    -I <includepath> ... Add an explicit include path.    -L <librarypath> ... Add an explicit library path.    -l <libraryname> ... Add an explicit library name, residing in a                         librarypath.    -graphicssystem <sys> Specify which graphicssystem should be used.                          Available values for <sys>: *                         raster - Software rasterizer                           opengl - Using OpenGL acceleration, experimental!                           openvg - Using OpenVG acceleration, experimental!    -help, -h, -? ...... Display this information.Third Party Libraries:    -qt-zlib ........... Use the zlib bundled with Qt. +  -system-zlib ....... Use zlib from the operating system.                         See http://www.gzip.org/zlib    -no-gif ............ Do not compile GIF reading support.    -no-libpng ......... Do not compile PNG support.    -qt-libpng ......... Use the libpng bundled with Qt. +  -system-libpng ..... Use libpng from the operating system.                         See http://www.libpng.org/pub/png    -no-libmng ......... Do not compile MNG support.    -qt-libmng ......... Use the libmng bundled with Qt. +  -system-libmng ..... Use libmng from the operating system.                         See See http://www.libmng.com    -no-libtiff ........ Do not compile TIFF support.    -qt-libtiff ........ Use the libtiff bundled with Qt. +  -system-libtiff .... Use libtiff from the operating system.                         See http://www.libtiff.org    -no-libjpeg ........ Do not compile JPEG support.    -qt-libjpeg ........ Use the libjpeg bundled with Qt. +  -system-libjpeg .... Use libjpeg from the operating system.                         See http://www.ijg.orgQt for Windows only:    -no-dsp ............ Do not generate VC++ .dsp files. *  -dsp ............... Generate VC++ .dsp files, only if spec "win32-msvc".    -no-vcproj ......... Do not generate VC++ .vcproj files. *  -vcproj ............ Generate VC++ .vcproj files, only if platform                         "win32-msvc.net".    -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 Do not embed manifests in plugins. *  -plugin-manifests .. Embed manifests in plugins.    -no-qmake .......... Do not compile qmake. *  -qmake ............. Compile qmake.    -dont-process ...... Do not generate Makefiles/Project files. This will                         override -no-fast if specified. *  -process ........... Generate Makefiles/Project files.    -no-rtti ........... Do not compile runtime type information. *  -rtti .............. Compile runtime type information.    -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    -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 dynamicall                         y    -dbus-linked ....... Compile in D-Bus support and link to libdbus-1    -no-phonon ......... Do not compile in the Phonon module +  -phonon ............ Compile the Phonon module (Phonon is built if a decent                         C++ compiler is used.)    -no-phonon-backend . Do not compile the platform-specific Phonon backend-pl                         ugin *  -phonon-backend .... Compile in the platform-specific Phonon backend-plugin    -no-multimedia ..... Do not compile the multimedia module *  -multimedia ........ Compile in multimedia module    -no-audio-backend .. Do not compile in the platform audio backend into QtMu                         ltimedia +  -audio-backend ..... Compile in the platform audio backend into QtMultimedi                         a    -no-webkit ......... Do not compile in the WebKit module +  -webkit ............ Compile in the WebKit module (WebKit is built if a                         decent C++ compiler is used.)    -webkit-debug ...... Compile in the WebKit module with debug symbols.    -no-script ......... Do not build the QtScript module. +  -script ............ Build the QtScript module.    -no-scripttools .... Do not build the QtScriptTools module. +  -scripttools ....... Build the QtScriptTools module.    -no-declarative .... Do not build the declarative module +  -declarative ....... Build the declarative module    -no-declarative-debug Do not build the declarative debugging support *  -declarative-debug . Build the declarative debugging support *  -no-directwrite .... Do not build support for DirectWrite font rendering    -directwrite ....... Build support for DirectWrite font rendering                         (experimental, requires DirectWrite availability on                         target systems, e.g. Windows Vista with Platform                         Update, Windows 7, etc.)    -arch <arch> ....... Specify an architecture.                         Available values for <arch>: *                         windows                           windowsce                           symbian                           boundschecker                           generic    -no-style-<style> .. Disable <style> entirely.    -qt-style-<style> .. Enable <style> in the Qt Library.                         Available styles: *                         windows +                         windowsxp +                         windowsvista *                         plastique *                         cleanlooks *                         motif *                         cde                           windowsce                           windowsmobile                           s60    -no-native-gestures Do not use native gestures on Windows 7. *  -native-gestures ... Use native gestures on Windows 7. *  -no-mp ............. Do not use multiple processors for compiling with MSVC    -mp ................ Use multiple processors for compiling with MSVC (-MP)    -loadconfig <config> Run configure with the parameters from file configure_                         <config>.cache.    -saveconfig <config> Run configure and save the parameters in file                         configure_<config>.cache.    -redo .............. Run configure with the same parameters as last time.Qt for Windows CE only:    -no-iwmmxt ......... Do not compile with use of IWMMXT instructions +  -iwmmxt ............ Do compile with use of IWMMXT instructions (Qt for                         Windows CE on Arm only) *  -no-crt ............ Do not add the C runtime to default deployment rules    -qt-crt ............ Qt identifies C runtime during project generation    -crt <path> ........ Specify path to C runtime used for project generation.    -no-cetest ......... Do not compile Windows CE remote test application +  -cetest ............ Compile Windows CE remote test application    -signature <file> .. Use file for signing the target project *  -phonon-wince-ds9 .. Enable Phonon Direct Show 9 backend for Windows CEQt for Symbian OS only: *  -no-freetype ....... Do not compile in Freetype2 support.    -qt-freetype ....... Use the libfreetype bundled with Qt.    -fpu <flags> ....... VFP type on ARM, supported options: softvfp(default) |                         vfpv2 | softvfp+vfpv2    -no-s60 ............ Do not compile in S60 support. *  -s60 ............... Compile with support for the S60 UI Framework    -no-usedeffiles .... Disable the usage of DEF files.    -usedeffiles ....... Enable the usage of DEF files.

这么多的选项,我建议用的:
-fast -static
剩下的你自己选,不需要的就用-no开头的,选好了回车,等它配置完成。
第四步,然后输入namke,最后它可能会报一个makefile.debug无法编译的错,这个不用管它,然后nmake install。
整个流程如下:

configure -fast -static ... ...nmakenmake install

这就完成了qt的编译了。
第五步,安装一个vs插件qt-vs-addin-1.1.7,安装完后就可以直接在vs2008里面建立QT工程了。

0 0
原创粉丝点击