I am going to start QT recently. I have heard it for a long time. QT's dynamic library mechanism makes QT programs extremely large. I must not tolerate this. If you are going to use the static library method, then compile the source code!
Below I will talk about the environment and the problems encountered. The article refers to http://blog.csdn.net/u011964923/article/details/52886908, but my report is wrong. . . Below is the solution.
1. Environmental issues
1. QT version: qt5.7 qt-opensource-windows-x86-msvc2013-5.7.0.exe
Download address: http://download.qt.io/archive/qt/5.7/5.7.0/
2. Install qt-vs-addin-1.25.exe
Download address: http://download.qt.io/official_releases/vsaddin/
3. Install python library and perl library. My environment is python2.7, and perl Baidu download is OK [ pay attention to setting environment variables ]
Here you can verify the success of the configuration by typing Python and perl -v under cmd.
4. VS2013 this Baidu download is ok. . . . . .
2. Start compiling the configuration
Then start to install qt-opensource-windows-x86-msvc2013-5.7.0.exe . Note here that you must check the installation source code at the beginning of the installation. Because we want to compile the source code. After installation, find the msvc-desktop.conf configuration file in the installation directory .
C:\Qt\Qt\xxx\qtbase\mkspecs\common\msvc-desktop.conf Note here that it must be this file under the source code folder src
Then you can happily modify it.
Will (actually is the way to compile)
QMAKE_CFLAGS_RELEASE = -O2 -MD QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi QMAKE_CFLAGS_DEBUG = -Zi -MDd change to QMAKE_CFLAGS_RELEASE = -O2 -MT QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi QMAKE_CFLAGS_DEBUG = -Zi -MTd
3. Compile
Open the VS2013 developer command prompt in Visual Studio Tools, cd into C:\Qt\Qt\xxx\src and
enter the following command:
configure -confirm-license -opensource -platform win32-msvc2013 -debug-and-release - static -prefix "C:\FreqUsed\Qt\-static-vs2013" -qt-sql-sqlite -qt-sql-odbc -plugin-sql-sqlite -plugin-sql-odbc -qt-zlib -qt-libpng -qt -libjpeg -opengl desktop -qt-freetype -no-qml-debug -no-angle -nomake tests -nomake examples
Press Enter and wait for about 1 minute.
Among them, "C:\FreqUsed\Qt\-static-vs2013" is the installation directory of the statically compiled version of qt I next.
After 1 minute, the command line will remind you nmake, then we type the nmake command and press Enter, wait 2 to 3 hours, and then enter nmake install, you can find the "C:\FreqUsed\Qt\-static-vs2013" this The directory is installing files, and after 10 minutes, the installation is complete.
Note: It started to report an error: nmake could not be completed. . .
nmake fatal error u1077: path/c1.exe return code 0x2
qnode_p.h(108): error C2955: 'Qt3DCore::QNodePrivate::DestructionFunction' : use of alias template requires template argument list qnode_p.h(105) : see declaration of 'Qt3DCore::QNodePrivate::DestructionFunction' qscene.cpp qnode_p.h(108) : error C2955: 'Qt3DCore::QNodePrivate::DestructionFun ction' : use of alias template requires template argument list qnode_p.h(105) : see declaration of 'Qt3DCore::QNodePrivate::DestructionFunction' Generating Code
Comment line 104 and 105: // template<typename Caller, typename NodeType> // using DestructionFunction = void (Caller::*)(NodeType *); Change line 108 from: void registerDestructionHelper(NodeType *, DestructionFunction, PropertyType); to: void registerDestructionHelper(NodeType *, void (Caller::*)(NodeType *), PropertyType); line 111 from: void registerDestructionHelper(NodeType *node, DestructionFunction<Caller, NodeType> func, NodeType *&) to : void registerDestructionHelper(NodeType *node, void (Caller::*func)(NodeType *), NodeType *&) line 119 from: void registerDestructionHelper(NodeType *node, DestructionFunction<Caller, NodeType> func, QVector<NodeType*> &) to : void registerDestructionHelper(NodeType *node, void (Caller::*func)(NodeType *), QVector<NodeType*> &)
【Qt Creator下的配置】 在工具->选项中...添加QT Version和构建套件,然后建立工程即可。
【VS下Qt插件的配置】网上的配置方法太过复杂,且成功率很低。让我纠结了一个下午,突然灵光一现,下面是我的方法:
1、先利用Qt Creator建立一个static版本的工程,设计好界面之后,编译成功。
2、将静态编译debug或release文件夹下的 “工程名_plugin_import.cpp”,复制到工程的main文件同一目录下
3、用VS的QT5打开刚才建立的工程,qt setting设置为静态版本
4、编译成功
支持xp 系统 在qt的.pro 文件中添加如下的代码就可以支持xp 了
win32 {
QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS,5.01
QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE,5.01
DEFINES += _ATL_XP_TARGETING
QMAKE_CFLAGS += /D _USING_V110_SDK71
QMAKE_CXXFLAGS += /D _USING_V110_SDK71
LIBS *= -L”%ProgramFiles(x86)%/Microsoft SDKs/Windows/7.1A/Lib”
INCLUDEPATH += “%ProgramFiles(x86)%/Microsoft SDKs/Windows/7.1A/Include”
}