注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

淘尽网 官方博客

淘尽网http://www.tao3w.com做最好的比价网站

 
 
 

日志

 
 
关于我

淘尽网 http://www.tao3w.com 做最好的比价网站,做最好的数据抓取专家。

网易考拉推荐

Building Qt 5 from Git  

2013-05-26 22:24:07|  分类: python |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
http://qt-project.org/wiki/Building-Qt-5-from-Git

Building Qt 5 from Git

Introduction

This article will try to give some hints for checking out the modularized Qt5 from git and getting it built. Please feel free to update this article as things change during development. Raise issues related to the article via: http://qt-project.org/forums/viewthread/7018

System Requirements

You need git (>= 1.6.x) to get the packages.

To properly configure and build Qt 5 from source you also need Perl (>=5.14) and Python (>=2.6.x), as well as a working compiler.

To enable SSL support in Qt, see: http://qt-project.org/doc/qt-5.0/qtnetwork/ssl.html

For more information regarding platform requirements, see: http://qt-project.org/doc/qt-5.0/qtdoc/requirements.html

Linux/X11

Build essentials

Ubuntu/Debian:

  1. sudo apt-get install build-essential perl python git

Note: Thanks to Gabor Loki, we have a custom PPA with a meta package “sedkit-env-webkit” that installs all required dependencies for the latest Qt/Qt WebKit builds. You can find it here – https://launchpad.net/~u-szeged/+archive/sedkit – or just add the PPA by issuing on the console:

  1. sudo apt-add-repository ppa:u-szeged/sedkit && sudo apt-get update && sudo apt-get install sedkit-env-qtwebkit

Fedora:
  1. su - -"yum install perl-version"
OpenSUSE:

  1. sudo zypper install git-core gcc-c++ make

Libxcb

Libxcb [xcb.freedesktop.org] is now the default window-system backend for platforms based on X11/Xorg, and you should therefore install libxcb and its accompanying packages. Qt5 should build with whatever libxcb version is available in your distro’s packages (but you may optionally wish to use v1.8 or higher to have threaded rendering support). src/plugins/platforms/xcb/README [qt.gitorious.org] lists the required packages.

Ubuntu/Debian:

  1. sudo apt-get install "^libxcb.*" libx11-xcb-dev libglu1-mesa-dev libxrender-dev

Fedora up to 16:
  1. su - -"yum install libxcb libxcb-devel xcb-util xcb-util-devel"
Fedora 17+ (xcb-util-renderutil is currently available in updates repository until it goes stable):
  1. su - -"yum --enablerepo=updates install libxcb libxcb-devel xcb-util xcb-util-devel xcb-util-*-devel"
OpenSuSE 12.2
  1. sudo zypper in xorg-x11-libxcb-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-renderutil-devel xcb-util-wm-devel xorg-x11-devel libxkbcommon-devel
ArchLinux:
  1. sudo pacman ---needed libxcb xcb-proto xcb-util xcb-util-image xcb-util-wm

On Chakra Linux, other than packages mentioned for ArchLinux, you need to install package xcb-util-keysyms separately. It’s available from CCR.

Mandriva/ROSA/Unity:
  1. urpmi 'pkgconfig(xcb)' 'pkgconfig(xcb-icccm)' 'pkgconfig(xcb-image)' 'pkgconfig(xcb-renderutil)' 'pkgconfig(xcb-keysyms)''pkgconfig(xrender)'

OpenGL support

For Qt Quick 2 a graphics driver with native OpenGL 2.0 support is highly recommended.

Accessibility

It is recommended to build with accessibility enabled, install libatspi 2 and libdbus-1 development packages.

Qt WebKit

When you want to compile WebKit, more dependencies need to be satisfied:

Ubuntu/Debian:

  1. sudo apt-get install flex bison gperf libicu-dev libxslt-dev ruby

Fedora:
  1. su - -"yum install flex bison gperf libicu-devel libxslt-devel ruby"
OpenSUSE:
  1. sudo zypper install flex bison gperf libicu-devel ruby
Mandriva/ROSA/Unity:
  1. urpmi gperf

Qt Multimedia

You’ll need at least alsa-lib (>= 1.0.15) and gstreamer (>=0.10.24but <1.0 for now [lists.qt-project.org]) with the base-plugins package.

Mac OS X

Install the latest Xcode from the App Store. Verify that your Xcode install is properly set up for command line use:

  1. xcodebuild -version && xcodebuild -showsdks

This should give you eg:

  1. Xcode 4.6.1
  2. Build version 4H512
  3. OS X SDKs:
  4.  Mac OS X 10.7                  -sdk macosx10.7
  5.  OS X 10.8                      -sdk macosx10.8
  6.  
  7. iOS SDKs:
  8.  iOS 6.1                        -sdk iphoneos6.1
  9.  
  10. iOS Simulator SDKs:
  11.  Simulator - iOS 5.0            -sdk iphonesimulator5.0
  12.  Simulator - iOS 6.1            -sdk iphonesimulator6.1

You can verify that the right Xcode is being used by running:

  1. xcode-select --print-path

If this points to /Developer you’re probably using an older Xcode version. Switch to the latest one by running:

  1. sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Windows

Windows Graphics Drivers

QML2 requires OpenGL 2.1 or higher or Open GL ES 2.0 to work.

In Windows, two options are available:

  1. Use the ANGLE-library [code.google.com] to translate OpenGL calls into DirectX (default)
  2. Use the native OpenGL driver for your graphics card

A copy of ANGLE is bundled in Qt 5. To use Option 1, you need to install the DirectX SDK [msdn.microsoft.com] (Note: Starting from Windows Kit 8, this is included in the Windows SDK).

To use Option 2, you need to ensure that your graphics card driver supports OpenGL 2.1 or higher (Note: The stock Windows driver only supports OpenGL 1.1, which is insufficient), and pass `-opengl desktop’ to configure.exe.

Supported Compilers on Windows

  • Windows SDK 7.1 with Visual Studio 2010 (recommended). As of 16.3.2012, installing the SDK requires installing the following packages in this order (see readme.html provided with the service pack):
  1. Install Visual Studio 2010
  2. Install Windows SDK 7.1. See also Cannot_Install_Windows_SDK page.
  3. Install Visual Studio 2010 SP1
  4. Install Visual C++ 2010 SP1 Compiler Update for the Windows SDK 7.1
  • Windows SDK 7 with Visual Studio 2008
  • Windows Kit 8 with Visual Studio 2012
  • MinGW-w64 based compiler with g++ version 4.7 or higher (e.g. MinGW-builds [sourceforge.net], see also MinGw-64-bit [qt-project.org] ).

Windows Build environment

We recommend creating a command prompt that provides the build environment (see the Qt Creator README [qt.gitorious.org] ). In this environment,Python (e.g. Active Python 2.7 later) and Perl (e.g. Active State Perl 5.12 or later) should be in the PATH.
Get Perl from: http://www.activestate.com/activeperl/downloads [activestate.com]
Get Python from: http://www.python.org/download/releases/ [python.org]
Get Ruby from: http://www.rubyinstaller.org/downloads/ [rubyinstaller.org]

Hint: Make sure that Perl is added to the path in front of git since that ships an outdated version (Perl 5.8), which will cause the scripts to fail.

Multicore building: To speed up building when using nmake, the compiler can be instructed to use all available CPU cores in one of the following ways:

  • Pass the option -MP to Qt’s configure
  • Set the environment variable CL (specifying Visual Studio compiler options) to /MP (On the command line: set CL=/MP)
  • Use the tool jom [qt-project.org] instead of nmake. Note however, that it has issues with module interdependencies, which can cause builds to fail.

ICU on Windows

Qt 5 can make use of the ICU [site.icu-project.org] library for UNICODE and Globalization support. This is required for building Qt WebKit. You can use precompiled versions of ICU with a Visual Studio 2010 dependency from the website, or compile ICU on your own .

At compile time, the absolute paths of include and lib folders of the ICU installation must be appended to INCLUDE and LIB environment variables after calling the setup script of the Windows SDK.

At run-time, the ICU DLLs need to be found. This can be achieved by copying the DLLs to the application folder or adding the bin folder of the ICUinstallation to the PATH environment variable.

Getting the source code

First clone the top-level Qt 5 git repository:

  1. git clone git://gitorious.org/qt/qt5.git qt5

or (if you’re behind a firewall and want to use the https protocol):

  1. git clone https://git.gitorious.org/qt/qt5.git qt5

Then check out the target branch (see Branch-Guidelines ):

  1. cd qt5
  2. git checkout stable

Following the README.git [qt.gitorious.org] – file we initialize the repository using the script init-repository which clones the various sub-modules of Qt 5. Relevant options:

  • --no-webkit : Consider skipping qtwebkit by passing this option. This module is quite big, takes a long time to compile and if often a source of compile errors, so it is recommend to only download it if you intend to use it. You can always re-run init-repository later on to add it.
  • --http : Pass this option if you’re behind a firewall.
  • --codereview-username <Jira/Gerrit username> : If you plan to contribute to Qt, you should specify your codereview username so that the git remotes are properly set up.

  1. cd qt5
  2. perl init-repository

Configuring and building

The Qt5 build system should be fairly resilient against any “outside distractions” – it shouldn’t matter whether you have other Qt versions in PATH, andQTDIR is entirely ignored. However, make sure that you have no qmake-specific environment variables like QMAKEPATH or QMAKEFEATURES set, and the qmake -query output does not refer to any other Qt versions ($HOME/.config/Trolltech/QMake.conf should be empty).

Configure the build (from top level dir). Disabling tests and examples will greatly speed up compilation:

For Linux/Mac OS X:

  1. ./configure -developer-build -opensource -nomake examples -nomake tests

For Windows:

  1. configure -developer-build -opensource -nomake examples -nomake tests

The -developer-build options export more symbols than in a traditional Qt build in order to allow more classes and functions to be unit tested. It also defaults to a ‘debug’ build, and installs the binaries in the current directory, avoiding the need for ‘make install’. ‘-opensource’ sets the license to beLGPL 2.1. The -nomake examples and -nomake tests parameters make sure examples and tests aren’t compiled by default. You can always decide to compile them later by hand.

  • Hint1: On Linux you should also pass -no-gtkstyle. This is because on a number of systems (at least SUSE and Gentoo) pkg-config —cflags gtk+-2.0 actually returns paths that include the system Qt 4.x include directories.
  • Hint2: You can add -confirm-license to get rid of the question whether you agree to the license.
  • Hint3: On Windows, you might not be able to build if sh.exe is in your PATH (for example due to a git or msys installation). Such an error is indicated by qt5-srcqtbasebinqmake.exe: command not found and alike. In this case, make sure that sh.exe is not in your path. You will have to re-configure if your installation is already configured.

Now trigger the build by running:

For Linux / Mac OS X:

  1. make -4

For Windows (MSVC), choose one of the following, depending on your setup/environment:

  1. nmake
  2. jom
  3. mingw32-make

Or only build a specific module, e.g. declarative, and modules it depends on:

  1. make module-qtdeclarative

Building Qt WebKit

Linux, Mac

The tools bisonflexgperf and ruby are required for building.

Windows

WebKit.org [trac.webkit.org] has instructions for building WebKit on Windows. ICU [site.icu-project.org] is required for building.

The tools bisonflex and gperf which are required for building are provided for convenience in the folder gnuwin32\bin. If you are using shadow builds, you must add this directory to your PATH, else no special actions need to be done manually in order to use them.

In addition you need to install Ruby [ruby-lang.org]

Installing (Linux / Mac OS X)

  • Note: Installation is only needed if you haven’t used the configure options -developer-build or -prefix “PWD/qtbase”. Otherwise you can just use Qt from the build directory.

To install, run

  1. make install

Cleaning

To get a really clean tree use:

  1. git submodule foreach --recursive "git clean -dfx"

since make confclean no longer works from the top-level of the repo.

Getting updates

To update both the qt5.git repo as well as the submodules to the list of revisions that are known to work, run

  1. git pull
  2. git submodule sync
  3. git submodule update --recursive

If you are planning to do nightly builds, consider using the script qt5_tool that lives in qtrepotools/bin. It provides options for updating the repository, cleaning and building. For example, qt5_tool -u -c -b can be used to clean, update and build. qt5_tool -p -c – b would be used to pull all modules to the head of their master branches.

Depending upon what changed in the source since it was last updated you might have to run configure again. To be really sure everything gets built, you can run clean first, then configure and make.

  • Hint1: git submodule update does a checkout in submodules, potentially hiding any local commits you’ve done! If the latter happened to you (and you haven’t been working with branches anyhow), git reflog is your friend ….
  • Hint2: When creating scripts for updates on Windows, note that git clean often fails if some process locks a file or folder.

Using latest branches in the submodules

By default the checkout will not contain the latest stable/dev branches of each individual submodule repository, but a combination of versions that are known to work together. If you want to get the absolute latest stuff you can do so on a per-module basis, e.g.

  1. cd qtdeclarative
  2. git fetch
  3. git checkout stable origin/stable

or use qt5_tool to update all repositories:

  1. ./qtrepotools/bin/qt5_tool -p

However, there’s a good chance that compilation will fail due to incompatible versions of submodules! You might want to ask other persons actively working on a module how to resolve these incompatibilities.

Issues

Linux

configure fails with “No QPA platform plugin enabled!” (Linux)

You should install the libxcb and it’s accompanying packages, see ‘System Requirements’.

configure fails with errors like “cannot stat file …”

Your perl version is too old, Qt 5 beta1 needs at least 5.14.

qmlscene segfaults “Cannot create platform GL context, none of GLXEGL, DRI2 is enabled” (Linux)

Try installing the libx11-xcb-dev package:

  1. sudo apt-get install libx11-xcb-dev

afterwards you have to re-run configure and force qtbase/src/plugins/platforms/xcb to recompile.

WebKit doesn’t compile, missing ICU

Currently there is no configure time check for ICU, so install it through the package manager through

on Ubuntu/Debian:

  1. sudo apt-get install libicu-dev

on Fedora:

  1. su - -"yum install libicu-devel"

  • You can also compile Qt without Qt WebKit by deleting / renaming the qtwebkit, qtwebkit-examples-and-demos directories.
  • The —no-webkit option of configure added, see QTBUG-20577 [bugreports.qt-project.org] issue.

Qt D-Bus fails to build due to “inconsistent user-defined literal suffixes”

This occours when you attempt to build Qt 5 with GCC 4.7 while D-Bus < 1.4.20 is present on your system. (For example, the default Fedora 17 installation is prone to this error.) The error message is this:

  1. qdbusinternalfilters.cpp:124:36: error: inconsistent user-defined literal suffixes ‘DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER’ and ‘DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER’ in string literal

Note: The error is in the header files of D-Bus itself, and it has been fixed upstream, see https://bugs.freedesktop.org/show_bug.cgi?id=46147
Solution: either upgrade to a newer version of D-Bus or edit that one line of the header file manually.

[…]::isNull is not defined (from qvariant_p.h)

C++11 support is detected while your GCC doesn’t properly support it
Fixed by passing

  1. -no-c++11

to the configure options

cc1: fatal error: .pch/release-shared/QtGui: No such file or directory

Currently unresolved bug with the build of assembly files, see discussion at http://comments.gmane.org/gmane.comp.lib.qt.devel/5933
Fixed by passing

  1. -no-pch

to the configure options

ld: hidden symbol `void QQmlThread::postMethodToThread<QQmlDataBlob*, QQmlDataBlob*, QQmlDataLoaderThread>(void (QQmlDataLoaderThread::)(QQmlDataBlob), QQmlDataBlob* const&)’ isn’t defined

Bug with GCC versions < 4.4.x, see bug report at https://bugzilla.redhat.com/show_bug.cgi?id=493929
Fixed by adding

  1. QMAKE_CXXFLAGS_RELEASE += -fno-inline

in qtdeclarative/src/qml/qml.pro

Windows

qdeclarative doesn’t compile because of missing v8.lib (Windows)

Compiling v8 in qtbase requires Python. Make sure you have a python.exe in your %PATH%, go to qtjsbackend, run qmake && nmake.

Debugging OpenGL issues (Windows)

Set the environment variable QT_QPA_VERBOSE=gl:1 and run the application with DebugView [technet.microsoft.com] installed. The log will show the requested vs obtained OpenGL version. If the log tells you that it only has OpenGL 1.1, QML2 will not work. Note that qmlscene will not report errors about unsupported OpenGL versions.

Questions & Comments

Please raise questions & comments about this article in the forum: http://qt-project.org/forums/viewthread/7018

Categories:

  评论这张
 
阅读(2276)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017