Qt 4.7.4 perfect dynamic compilation release dynamic debugging and static compilation release

Source: Internet
Author: User

Original article address:Http://blog.csdn.net/cjyl25/article/details/6899229

The first step is preparation. Go to the QT homepage to download the independent QT class library installation package, the complete qt sdk installation package, and QT Creator for Windows.

: Http://qt.nokia.com/downloads-cn Latest Version 4.7.4

There is also a static version of mingw 4.4.5, used to solve the problem of mingwm10.dll, libgcc_s_dw2-1.dll, two DLL Dependencies

Yes: http://code.google.com/p/qp-gcc/downloads/list

The four files are:

(1) qt-creator-win-opensource-2.3.1.exe // IDE development framework

(2) qt-win-opensource-4.7.4-mingw.exe // QT class library installation package

(3) qt_sdk_win_offline_v1_1_3_en.exe // complete installation package of QT SDK

(4) mingw-static-4.4.5-all.7z // mingw static compilation full version


After preparing the above four files, you can install them. The installation sequence is as follows (1) -- (4 ).

The following describes the precautions for installation,

Step 1: Install QT-creator. Remember to select the built-in mingw compiler during installation (mainly for this mingw compiler ). If the default installation to: C: \ QT \ qtcreator-2.3.1

Step 2: Install the QT independent class library. because it does not contain the compiler, You must select the mingw compiler path as an option during installation,

Point to the C: \ QT \ qtcreator-2.3.1 \ mingw directory. If it is installed in: C: \ QT \ 4.7.4 By default

Step 3: Install the full qt sdk, which is installed in c: \ qtsdk by default.


Okay, next is the key static compilation, open the qmake. conf file under the c: \ QT \ 4.7.4 \ mkspecs \ win32-g ++ directory,

Modify two places:

Qmake_lflags =

 

Change

Qmake_lflags =-static-enable-stdcall-fixup-wl,-enable-auto-import-wl,-enable-runtime-pseudo do-reloc

Add

Qmake_lflags_dll =-shared

Change

Qmake_lflags_dll =-static

Open the "Start Menu"> "program"> "QT by Nokia v4.7.4 (mingw opensource)" menu and the QT 4.7.4 command prompt is the QT command line,

Configure the compilation option first and then start compilation. This is the command line prompt in the path C: \ QT \ 4.7.4. Enter the following configuration command:

Configure-platform win32-g ++-release-opensource-static-fast-QT-SQL-SQLite-plugin-SQL-SQLite-no-qt3support-QT-zlib-QT-GIF-QT-libpng -QT-libmng-QT-LibTIFF-QT-libjpeg-no-WebKit-QT-style-WindowsXP-QT-style-windowsvista-nomake examples-nomake docs-nomake demos

After the configuration is complete, go to the src directory and compile it. Enter the following command:

Cd src // enter the source code directory

Mingw32-make-I-K // for static Compilation


After a few minutes, the compilation will be successful, and then you can proceed to step 4.


Step 4: Compile the downloaded mingw static version.Mingw-static-4.4.5-all.7z decompress to c: \ qtsdk \ mingw directory, why?

Because we need to use the QT-creator IDE in the full qt sdk installed in step 3 for development, rather than the QT-creator installed in step 1.

In the final setting, open the QT-creator, click "Tools"> "options" dialog box, and click "qt4" on the left to see that the IDE automatically detects

But the automatically detected qmake can only generate dynamically compiled programs. Now we click "add" in the upper right corner to find the path

C: \ QT \ 4.7.4 \ bin, select the qmake.exe file in the path, name it "QT 4.7.4 static compilation", and confirm that the final settings are complete.


Now let's create a new qt gui application. When setting the target, select "desktop". We can see the default dynamic mingw compiler and ourselves.

Named static mingw compiler. For example, I remember that debugging of static compilation cannot be generated because I didn't perform static compilation of debugging, just

The release is statically compiled. Although the installation space is relatively large, it saves you trouble to modify the makefile. debug file during debugging.


Share:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.