Linux下编译Qt 5版本源码

由于需要基于Centos下调用Qt的webkit来进行web相关的开发工作,所以需要对Qt进行源码编译,再编译出对应的webkit相关的库来。

在编译的过程中,遇到了一些坑,特此记录一下。

Qt源码编译过程:

  1. 下载Qt源码
  2. 先检查配置:

./configure

2.1 检查配置报错:

Creating qmake...
gmake: Nothing to be done for `first'.
Running configuration tests...
The test for linking against libxcb and support libraries failed!
 You might need to install dependency packages, or pass -qt-xcb.
 See src/plugins/platforms/xcb/README.

看到这个报错后,第一时间就是百度查,经过了很长时间,百度翻了个遍也没找到。
回过头来,发现这个报错信息其实已经很明确了,指明遇到问题时查看See src/plugins/platforms/xcb/README。仔细读一下这个Readme,里面已经指明了需要安装的依赖项。唉,总是犯这种低级的老毛病。然后安装上相关的依赖:

Requires libxcb >= 1.5.

PACKAGE DEPENDENCIES

Required packages:
libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm1 libxcb-icccm1-dev libxcb-sync0 libxcb-sync0-dev libxcb-render-util0 libxcb-render-util0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-glx0-dev

On Ubuntu 11.10 icccm1 is replaced by icccm4 and xcb-render-util is not available:
libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-sync0 libxcb-sync0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-glx0-dev
The packages for xcb-render-util can be installed manually from http://packages.ubuntu.com/natty/libxcb-render-util0 and http://packages.ubuntu.com/natty/libxcb-render-util0-dev

On Ubuntu 12.04 icccm1 is replaced by icccm4 and xcb-render-util can be installed automatically:
libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-sync0 libxcb-sync0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0 libxcb-render-util0-dev libxcb-glx0-dev

On Fedora, the following packages are required:
libxcb libxcb-devel libXrender libXrender-devel xcb-util-wm xcb-util-wm-devel xcb-util xcb-util-devel xcb-util-image xcb-util-image-devel xcb-util-keysyms xcb-util-keysyms-devel

REDUCING RUNTIME DEPENDENCIES

The '-qt-xcb' configure option can be used to get rid of most xcb- dependencies. Only libxcb will
still be linked dynamically, since it will be most likely be pulled in via other dependencies anyway.
This should allow for binaries that are portable across most modern Linux distributions.

2.2 安装ICU

yum install icu.x86_64
yum install libicu-devel.x86_64

2.3 安装OpenSSL

yum install openssl-devel.x86_64 
  1. 开始编译:

make -j8

  1. 开始安装:

make install

QtWebkit编译过程:

  1. 安装依赖
    1.1 安装perl相关包
    yum install perl-*
    1.2 安装gperf相关包
    yum install gperf.x86_64
    1.3 安装ruby相关包
    yum install ruby.x86_64
  2. 编译webkit
    ./qtwebkit/Tools/Scripts/build-webkit --qt --debug

猜你喜欢

转载自blog.51cto.com/xdataplus/2678579