Statically compiled Qt5.4.1 and QT WebKit

Source: Internet
Author: User

Blog article address: http://godebug.org/index.php/archives/133/

WebKit is a good thing, do crawlers, display Web pages or want to use HTML to do desktop application interface can use him, but has always felt that he compiled WebKit thankless, so are used by the official Qt compiled, as for the static compilation WebKit, I have always thought is simply impossible. Later to see QT Forum said it is actually possible, but because of the problem of open source protocol qt default static compilation just WebKit to exclude, their own compilation of WebKit is good, so, then I will be a small white try. But finally found that static compilation WebKit is actually not difficult, is more trouble, occupy dozens of G hard drive lasted a day finally put this thing compiled. So simply remember the compilation process, convenient for everyone. But we have to remind you that the closed source project static link Qt and WebKit are in violation of the LGPL protocol, unless you open your program under the GPL agreement, or it is illegal.

The first is the installation of a messy tool
1.Python, I used PY 2.7 and 3.3 on my machine, but it was compiled with 2.7.
2.Ruby, I installed is 2.2.1, official online said need Ruby, but in the process of compiling I did not find where to use this thing, and in Windows to put a Ruby is not too useful, you can not install him, and so on when the compilation of problems to install also not later, I'm not going to try and need it.
The compilation scripts for 3.perl,webkit and OpenSSL are written by Perl, which is definitely going to be used.
4.OpenGL ES SDK, I do not know why to use this thing, I clearly selected is-opengl desktop, is estimated to be a QT bug
4. A compiler, see what you want to use, I use the vs2013

These are all installed after the addition of two third-party libraries, ICU and OPENSSL,ICU are required to compile WebKit, OpenSSL is not required, provided that you do not intend to use WebKit to access the HTTPS website ...
I began to try to compile the ICU myself, this goods is not too difficult to compile, but it is not a compilation option can be changed to use static runtime, to change the config and makefile files, I am lazy to move, found a ready-made precompiled ICU, But with the ICU here there is a problem, it is provided by the static compiled ICU library wood has PDB debugging information, in the link will have a bunch of LNK4099 warning, this idiot warning although can be determined to be completely human harmless (we almost could not debug the code inside the ICU), But because the VS has a fucked-up bug, this wrning is impossible to block, and because Qtcore also uses ICU, you will see a bunch of LNK4099 warning in every QT project ... Every time the compilation ... WTF ... If you do not want to see, you compile the ICU, this link also gives the ICU static link run when the patch, self-clothed.
Compile OpenSSL I don't have to say it, it's simple, I've written http://www.godebug.org/index.php/archives/104/before.

All done, began to compile QT, directly download the source code ZIP format, do not use tar, the lack of configure.exe, it is for Linux, decompression, I put in F:\qt-everywhere-opensource-src-5.4.1\, The configuration file in the Mkspace is then modified because QT does not have the option to modify from the command line to use the static runtime, to find the qtbase\mkspace\ compiler name \ qmake.conf, editing, the inside of the two MD are changed to MT, a MDD to MTD can be, I use here is VS,GCC words should be qmake_cxxflags an item in Add a-static, save on can.
And then set the environment variables, here I recommend to directly block the environment of the system variables, all reset, because the system installed in the mess of tools are likely to affect the compilation, such as installed Msysgit what, the inside of the Perl.exe will have an impact. Open a command prompt CD to the root directory of the source code,

SetPATH=C:\ windows;C:\Windows\System32;D:\ruby22-x64\bInch;C:\python27;C:\python27\scripts;F:\icu\lib;F:\icu\bInch;F:\gles_sdk\x86;D:\perl64\bInch;F:\openssl\bInch;SetINCLUDE=f:\icu\include; F:\gles_sdk\include;:\openssl\include;set Lib=f: \icu\lib;:\gles_sdk\x86; F:\openssl\lib; "D:\Program Files (x86) \microsoft Visual Studio 12.0\vc\vcvarsall.bat"  x86  

The path above should be replaced by the corresponding directory. Then you can configure it:

Configure-Prefix D:\qt\static541_2013-Debug-and-Release-OpenSource-Static -Nomake examples-no-compile-examples Span class= "pun" >-opengl desktop -openvg - platform win32-msvc2013 - target xp -sse4. 2 -no-AVX -no-avx2 - icu -openssl-linked   

Configure finished directly nmake then nmake install, after a long wait, no problem in D:\Qt\Static541_2013 can see the compiled lib.
At this time the static version of QT has been compiled, and then it should be webkit.
Do not close the command prompt after compiling, and then execute the following commands:

SetPATH=%PATH%D:\qt\static541_2013\bInch;F:\qt-Everywhere-OpenSource-Src-5.4.1\gnuwin32\bInch;SetINCLUDE=%INCLUDE%D:\qt\static541_2013\include;SetLib=%Lib%D:\qt\static541_2013\lib;D:\qt\static541_2013\plugins;D:\qt\static541_2013\plugins\audio;D:\qt\static541_2013\plugins\bearer;D:\qt\static541_2013\plugins\designer;D:\qt\static541_2013\plugins\geoservices;D:\qt\static541_2013\plugins\iconengines;D:\qt\static541_2013\plugins\imageformats;D:\qt\static541_2013\plugins\mediaservice;D:\qt\static541_2013\plugins\platforms;d:\qt\static541_2013\plugins\playlistformats d:\qt\static541_2013\plugins\positiond:\qt\static541_2013\plugins\printsupport d:\qt\static541_2013\plugins\qml1tooling d:\qt\static541_2013\plugins\qmltooling d:\qt\static541_2013\plugins\sensorgestures d:\qt\static541_2013\plugins\sensors  

The last set command of a large heap of plugin lib directory should be no add, Qmake will find these lib, but I have not tested (and do not want to try), who is interested can try. And then it's compiled WebKit.

perl F:\qt-everywhere-opensource-src-5.4.1\qtwebkit\Tools\Scripts\build-webkit --qt --prefix=d:\Qt\QtWebkit

Here prefix seems to add and not add a kind, anyway compiled will automatically put the generated lib to the QT SDK directory, this prefix specified directory but nothing. The long wait for fried chicken. Look at the machine performance, I was compiled anyway about 5, 6 hours, during the machine card, you can only see a Web page or e-book.
Compile is smooth, only encountered an error, because there is no judge whether it is static compilation, with the DllImport:

Open the F:\qt-everywhere-opensource-src-5.4.1\qtwebkit\Source\WebCore\platform\qt\QtTestSupport.h and put

#if defined(BUILDING_WEBKIT)#define TESTSUPPORT_EXPORT Q_DECL_EXPORT#else#define TESTSUPPORT_EXPORT Q_DECL_IMPORT#endif

Change to:

#if defined(BUILDING_WEBKIT)#define TESTSUPPORT_EXPORT /*Q_DECL_EXPORT*/#else#define TESTSUPPORT_EXPORT /*Q_DECL_IMPORT*/#endif

Re-run the above compilation command, all the way, finally compiled ... After compiling, he will automatically copy the Qtwebkit lib to the directory where your QT SDK is located, followed by the Qt creator or QT vs plugin.

I tried to compile a qt example in the browser project, got a 51.1mb exe,upx-9 a bit to become 16.6m, in addition to my hand to compile Qt time forgot to add OpenSSL, so there is no access to HTTPS site features are not missing ( The above tutorial is in accordance with the addition of OpenSSL to write, I also too lazy to compile, have time to say it.

In addition, according to my experience in compiling QT, General qt5.x.0 compilation is more or less a variety of problems, either grammatical problems, or less things, or the path is not right, but will soon release a 5.x.1 and 5.x.2 generally no problem, why so do not know.

http://www.ituring.com.cn/article/195148

Http://www.qtcn.org/bbs/read-htm-tid-59674-page-e.html#a

Statically compiled Qt5.4.1 and QT WebKit

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.