在CentOS下面编译WizNote Qt Project

注:本文是2.3.2的安装步骤。  2.3.3版本可先参为知笔记用户Linjie写的博文:http://linjie.org/2016/08/25/compile-install-wiznote/

 

编译环境

  1. CentOS 64位 Desktop 版本:6.5

编译前的准备:

CentOS的用户默认没有root权限,如果当前用户没有权限root,则可以在终端里面执行下面的命令:

su root
sudo sed -i '/root\tALL=(ALL)/a *自己的用户名*\tALL=(ALL)\tALL' /etc/sudoers
exit

需要替换自己的用户名

安装git

sudo yum install git

安装开发工具

sudo yum groupinstall "Development Tools"

安装开发库

sudo yum install libX11-devel, libXext-devel, libXtst-devel
sudo yum install libX11-devel libXext-devel libXtst-devel
sudo yum install libXrender-devel
sudo yum install zlib-devel
sudo yum install openssl-devel
sudo yum install flex bison gperf libicu-devel libxslt-devel ruby
sudo yum install libxcb libxcb-devel xcb-util xcb-util-devel
sudo yum install freetype-devel
sudo yum install fontconfig-devel

下载安装qt 4.8.6

wget http://download.qt-project.org/official_releases/qt/4.8/4.8.6/qt-everywhere-opensource-src-4.8.6.tar.gz
tar xvfz qt-everywhere-opensource-src-4.8.6.tar.gz
cd qt-everywhere-opensource-src-4.8.6
./configure -webkit
gmake
sudo gmake install

注意 在执行 ./configure -webkit 命令的时候,需要确保webkit, ssl,fontconfig,XRender能够被正确编译,如下: Qt 3 compatibility ..... yes
QtDBus module .......... no
QtConcurrent code ...... yes
QtGui module ........... yes
QtScript module ........ yes
QtScriptTools module ... yes
QtXmlPatterns module ... yes
Phonon module .......... no
Multimedia module ...... auto
SVG module ............. yes
**WebKit module .......... yes**
JavaScriptCore JIT ..... To be decided by JavaScriptCore
Declarative module ..... yes
Declarative debugging ...yes
Support for S60 ........ no
Symbian DEF files ...... no
STL support ............ yes
PCH support ............ yes
MMX/3DNOW/SSE/SSE2/SSE3. yes/yes/yes/yes/yes
SSSE3/SSE4.1/SSE4.2..... yes/yes/yes
AVX..................... yes
Graphics System ........ default
IPv6 support ........... yes
IPv6 ifname support .... yes
getaddrinfo support .... yes
getifaddrs support ..... yes
Accessibility .......... yes
NIS support ............ yes
CUPS support ........... no
Iconv support .......... yes
Glib support ........... no
GStreamer support ...... no
PulseAudio support ..... no
Large File support ..... yes
GIF support ............ plugin
TIFF support ........... plugin (qt)
JPEG support ........... plugin (qt)
PNG support ............ yes (qt)
MNG support ............ plugin (qt)
zlib support ........... system
Session management ..... no
OpenGL support ......... no
OpenVG support ......... no
NAS sound support ...... no
XShape support ......... yes
XVideo support ......... no
XSync support .......... yes
Xinerama support ....... no
Xcursor support ........ no
Xfixes support ......... no
Xrandr support ......... no
**Xrender support ........ yes**
Xi support ............. no
MIT-SHM support ........ yes
**FontConfig support ..... yes**
XKB Support ............ yes
immodule support ....... yes
GTK theme support ...... no
SQLite support ......... plugin (qt)
**OpenSSL support ........ yes (run-time)**
Alsa support ........... no
ICD support ............ no
libICU support ......... yes
Use system proxies ..... no
如果上面几个显示的是no,那么请重新安装前面的开发库。 QT编译耗时很长,请慢慢等待。

编译安装cmake

因为CentOS自带的cmake(或者通过rpm安装的cmake)版本比较低,因此需要自己编译安装。wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz
tar -zxv -f cmake-2.8.12.2.tar.gz
cd cmake-2.8.12.2
./configure
gmake
sudo make install

下载编译WizNote

git clone https://github.com/WizTeam/WizQTClient.git
cd WizQTClient
git checkout testing
./centos-package.sh

如果没有错误,则会在WizQTClient同级目录下面,生成一个WizNote文件夹,进入后可以执行bin/wiznote来运行WizNote。

安装QtCreator

注意:如果您不需要开发,则不需要安装QtCreator即可。如果需要开发调试,可以安装。

因为CentOS上面的libstdc++.so.6 版本太低,因此还需要编译安装gcc才可以正确运行QtCreator。

首先,从qt-project.org 下载QtCreator并且安装。安装后运行QtCreator,通常会提示有些插件无法加载,从而导致无法正常打开工程。我们需要编译gcc。

编译安装gcc

配置过程中需要联网安装需要的依赖。

wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.8.1/gcc-4.8.1.tar.bz2
tar -jxvf gcc-4.8.1.tar.bz2
cd gcc-4.8.1
./contrib/download_prerequisites
cd ..
mkdir gcc-build-4.8.1
cd gcc-build-4.8.1
../gcc-4.8.1/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
make -j4
sudo make install

到这里可以编译并安装最新版本的gcc。但是因为系统里面的libstdc++.so.6在 /usr/lib64 里面,而我们安装的在 /usr/local/lib64里面,因此需要更新一下链接。

sudo rm /usr/lib64/libstdc++.so.6
sudo ln -s /usr/local/lib64/libstdc++.so.6.0.18 /usr/lib64/libstdc++.so.6

然后重新打开QtCreator,就可以正常运行了。

最后,我们自己编译的qt library在/usr/local/Trolltech/Qt-4.8.5 里面,需要在QtCreator选项里面指定。

如果使用QtCreator打开WizNote工程并编译,请参考文章:在Ubuntu下面编译WizNote Qt Project