首先下载源码
qt-creator-2.4.1-src.tar.gz 图形开发环境
qt-everywhere-opensource-src-4.8.0.tar.gz QT源码,编译成QT的库和qmake
解压文件包到系统
mkdir /usr/local/QT 所有的QT相关的文件都定义到该目下,便于管理
tar xvf qt-everywhere-opensource-src-4.8.0.tar.gz -C /usr/local/QT/
tar xvf qt-creator-2.4.1-src.tar.gz -C /usr/local/QT/
新建需要的目录
mkdir /usr/local/QT
mkdir /usr/local/QT/qt_x11 编译PC上跑QT程序的库路径
mkdir /usr/local/QT/qt_embeded_x86 编译PC上模拟qvfb跑QT程序的库路径
mkdir /usr/local/QT/qt_arm 编译ARM跑QT的库
mkdir /usr/local/QT/qvfb 存放qvfb工具目录
mkdir /usr/local/QT/shell 存放选择设置库环境变量的shell脚本目录
需要安装QT需要的lib,参考例:doc\html\requirements-x11.html 编译X11依赖的lib
1. PC版搭建,即X11安装,可以参考源码下的文件
/doc/html/requirements-x11.html 安装X11之前需要安装的库,QT的依赖关系
/doc/html/install-x11.html 安装QT的方法
a) QT库编译
cd /usr/local/QT/qt-everywhere-opensource-src-4.8.0
./configure -prefix /usr/local/QT/qt_x11
make
make install
b) QT库路径设定
cd /usr/local/QT/shell
touch setenv_qt_x11.sh
vim setenv_qt_x11.sh
在setenv_qt_x11.sh中添加:
##########################
QTDIR=/usr/local/QT/qt_x11
PATH=$PATH:$QTDIR/bin
MANPATH=$MANPATH:$QTDIR/doc/man
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$QTDIR/lib
export QTDIR PATH MANPATH LD_LIBRARY_PATH
##########################
2.X86版本(跑QT qvfb时需要的)
a) QT库编译
cd /usr/local/QT/qt-everywhere-opensource-src-4.8.0
./configure -prefix /usr/local/QT/qt_embeded_x86 -embedded x86 -qvfb (-qvbf 指定编译虚拟framebuffer,模拟器使用)
make
make install
b) QT库路径设定
cd /usr/local/QT/shell
touch setenv_qt_embeded_x86.sh
vim setenv_qt_embeded_x86.sh
在setenv_qt_embeded_x86.sh中添加:
##########################
QTDIR=/usr/local/QT/qt_embeded_x86
PATH=$PATH:$QTDIR/bin
MANPATH=$MANPATH:$QTDIR/doc/man
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$QTDIR/lib
export QTDIR PATH MANPATH LD_LIBRARY_PATH
##########################
3.嵌入式ARM QT
a) QT库编译
cd /usr/local/QT/qt-everywhere-opensource-src-4.8.0
./configure -prefix /usr/local/QT/qt_arm -embedded arm
make
make install
b) QT库路径设定
cd /usr/local/QT/shell
touch setenv_qt_arm.sh
vim setenv_qt_arm.sh
在setenv_qt_arm.sh中添加:
##########################
QTDIR=/usr/local/QT/qt_arm
PATH=$PATH:$QTDIR/bin
MANPATH=$MANPATH:$QTDIR/doc/man
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$QTDIR/lib
export QTDIR PATH MANPATH LD_LIBRARY_PATH
##########################
4. qvfb工具编译
a) qvfb编译
cd /usr/local/QT/qt-everywhere-opensource-src-4.8.0
cd ./tools/qvfb
make
cp ../../bin/qvfb /usr/local/QT/qvfb
若不成功则:
cd //usr/local/QT/qt-everywhere-opensource-src-4.8.0/src/plugins/gfxdrivers/qvfb
qmake
make install
5. PC 上QT程序的运行:
写代码
qmake -project 生成.pro
qmake
make
6. QT程序指定安装路径
在.pro文件中添加:
target.path = /usr/local/myapp
target.files = *.cpp qtDemo
unix:target.extra = ls&&echo 1
INSTALLS += target
7.ubutu直接sudo apt-get install libqt4-dev 直接安装QT库,然后设置环境变量就OK了