Ubuntu12.04下交叉编译Qt4.8.2步骤

1.安装支持库

#sudo apt-get install build-essential

#sudo apt-get install libxrender-dev libxrandr-dev libxcursor-dev libxinerama-dev libxi-dev libxt-dev libglib2.0-dev libxtst-dev

2.切换到su用户

#sudo passwd

#su

2.安装交叉编译环境

将gcc编译器复制到/usr/local下面,并设置环境变量

#export PATH=$PATH:/usr/local/arm-gcc/bin

注:gcc编译器的位数与Ubuntu系统的位数应一致,均为32位或64位

查看Ubuntu系统位数命令为:#nname -ar

查看文件信息命令为:#file filename

3.解压Qt源码

#tar xzvf qt-opensource.4.8.2.tar.bz2

修改qt-everywhere-opensource-src-4.8.2/mkspecs/qws/linux-arm-g++/qmake.conf文件,使编译器名称为上面安装的编译器,如下所示:

QMAKE_CC                = arm-angstrom-linux-gnueabi-gcc
QMAKE_CXX               = arm-angstrom-linux-gnueabi-g++
QMAKE_LINK              = arm-angstrom-linux-gnueabi-g++
QMAKE_LINK_SHLIB        = arm-angstrom-linux-gnueabi-g++

# modifications to linux.conf
QMAKE_AR                = arm-angstrom-linux-gnueabi-ar cqs
QMAKE_OBJCOPY           = arm-angstrom-linux-gnueabi-objcopy
QMAKE_STRIP             = arm-angstrom-linux-gnueabi-strip


注:Qt源码的位数也应与Ubuntn系统和GCC编译器的位数一致

4.进入qt源码目录进行配置

#./configure -qt-kbd-tty -qt-kbd-linuxinput -qt-gfx-linuxfb -qt-gfx-transformed -qt-gfx-multiscreen -qt-mouse-pc -qt-gfx-qvfb -qt-gfx-vnc -prefix /usr/local/Trolltech/QtEmbedded-4.8.2-arm -opensource -confirm-license -release -shared -embedded arm -xplatform qws/linux-arm-g++ -depths 16,18,24 -fast -optimized-qmake -pch -qt-sql-sqlite -qt-libjpeg -qt-zlib -qt-libpng -qt-freetype -little-endian -host-little-endian -no-qt3support -no-libtiff -no-libmng -no-opengl -no-mmx -no-sse -no-sse2 -no-3dnow -no-openssl -no-webkit -no-phonon -no-nis -no-opengl -no-cups -no-glib -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-separate-debug-info -nomake examples -nomake tools -nomake docs

5.#make

6.#make install

7.设置环境变量

编辑/etc/profile

#gedit /etc/profile

在文件末尾追加以下信息:

export QTDIR=/usr/local/Trolltech/QtEmbedded-4.8.2-arm
export T_ROOT=/usr/local
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$T_ROOT/lib:$QTDIR/lib
export QMAKESPEC=$QTDIR/mkspecs/qws/linux-arm-g++

8.重启Ubuntu



你可能感兴趣的:(ubuntu,gcc,qt,Path,library,编译器)