is QT compiling slow?

Source: Internet
Author: User

1. "Program compiled with QT is slower than MFC" is wrong
Absolute error, Unit code number of lines compiled QT is much faster than MFC, because the QT library header file design is very good, as far as possible to use the pre-declaration, avoid the header file nesting, almost all classes use the public class and private class design, the unnecessary disclosure of the declaration into the private header file, to avoid the introduction of excessive code at compile time. and MFC does not have such a design.
As for everyone feel MFC fast main reason is MFC project by default open the compilation preprocessing header file (PCH), but this is the characteristics of the VC compiler, all C + + programs can be used, not MFC-specific, QT can also use the PCH
Method is simple, add a row to your. Pro file

Precompiled_header = stable.h

Specify Stable.h this header file as a compilation preprocessing file, MFC This file is generally called stdafx.h
Then include all the QT header files you use in the stable.h, and if you use a lot of QT classes you can directly include all
Like what:

#include <QtCore>
#include <QtGui>

These two files also contain almost all of the QT common classes
Don't worry, even if all the header files are included, it doesn't matter if you have a PCH and a long file.

If you still want to compile faster, you can add the following line to the. Pro

Qmake_cxxflags + =/MP

Specifying the/MP compilation option, the compiler will use parallel compilation and compile different CPP concurrently with multiple compilation processes

And Qt This method of introducing PCH is better than MFC, because MFC's PCH option is specified per project, it is easy to be bad for some people, I have fixed the PCH problem countless times, but the QT option is written in the. Pro, write once will never be wrong.
Once the MFC has broken the PCH, the compilation is also very slow.

Give a reference time, yy latest version about more than 1 million lines C + + code, rebuild debug and Releae a total of more than 20 minutes, the machine is i5 four-core SSD hard disk. In fact, for large projects hard disk is the bottleneck, if you change the mechanical hard drive to be about 70% slower, a colleague with 10G of memory made a memory disk to compile, but also fast 30%.

If you are slower than this, check your code problems.

2. "QT itself is compiling slowly," the saying is wrong
QT itself is actually compiled not slow, slow is WebKit library and example program, if you do not change any option by default will compile all, WebKit itself is a dinosaur-level project, with too many generic technology, compile very slow. In addition, QT comes with hundreds of example projects, all compiled on one side is also very slow. If only the QT core library is compiled quickly, such as Qtcore only takes 1 minutes, Qtgui about 5 minutes.

Send a benefit (Windows VC + + 2008 only):

Configure.exe-qt-libjpeg-qt-zlib-qt-libpng-qt-libjpeg-qt-gif-no-libtiff-no-libmng-nomake Examples-nomake de Mos-no-webkit-nomake Doc-no-plugin-manifests-no-exceptions-no-rtti-no-qt3support-no-openssl-no-opengl- No-multimedia-no-3dnow-no-native-gestures-no-style-motif-no-style-cde-no-style-cleanlooks-no-style-plastique- No-sql-sqlite-no-dbus-platform win32-msvc2008


This is my own use of the QT pre-compilation configuration command line, I do not have to use the removal of all, so the configuration of the compilation is much faster.
I took WebKit examples demos and all the big guys out. If you really need this, you can install a compiled version of the QT SDK.

Add: Qt Creator is just the IDE, not the compiler, compiling slow really does not concern him, depends on your specific compiler is what. In general, under Windows is MinGW, that is, a ported version of GCC, it is not as fast as the VC in the CL.
If it is a different platform, then the compiler can be replaced with LLVM clang, it is much faster.

In Windows is to use VC + +, recommended VS2013,QT and VC IDE combined very well, I am now the project is to use VC2013+QT, development efficiency is high, remember to install visual assist OH.

QMAKE-TP VC

You can use the. Pro production. Vcproj VC project files, can be opened with VC + + compile.

References

http://www.zhihu.com/question/23045749

is QT compiling slow?

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.