【转】qt交叉环境编译
突然想到一个问题,是不是搞QT的人都清楚qt的名字,以及之间的关系。把名字变来变去,似乎是一件“好玩”的事。对开发者来说,是一件“痛苦”的事。
对于QT编译,我想,创立"qt编译学"是很有必要的,哈哈。
qt编译是否成功,依赖系统环境(包括环境变量,需要的库),还有开发者操作。
从心理学侦探学犯罪学的角度来看,编译qt(对于其他编译好像也可以),应该把自己当作侦探,不要期望凶手会自首,应该从每个error上发现线索,抓到凶手。
为了方便设置,写了一个设置环境变量的shell脚本qtenv,去掉原本已经被我设得不堪入目的变量,重新再来一遍。干净的,顺序上qt优先,然后交叉编器,最后是系统(不清楚是否有关系)。
- #!/bin/sh
- #by oChapman
- #2009-5-29
- #qt environment setting.
- echo "setting env"
- export QTDIR=/work/qt-2.3.7
- export QPEDIR=/work/qtopia-1.7.0
- export LD_LIBRARY_PATH=/usr/local/arm-linux/qt_toolchain/qt-2.3.2/lib:/usr/local/arm-linux/lib:/usr/local/bin:/usr/local/lib:/lib
- export TMAKEDIR=/work/tmake-1.11
- export TMAKEPATH=/work/tmake-1.11/lib/qws/linux-arm-g++
- export PATH=/work/tmake-1.11/bin:/usr/local/arm-linux/bin:/usr/local/arm-linux/arm-linux/lib:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
- export CC=arm-linux-gcc
- echo "ok"
运行之(注意, 是". ~/qtenv" ),
之后,按照编译步骤,再一次出现成功。
系统:ubuntu 8.04
QT:
qt-2.3.7
qtopia-1.7.0
tmake-1.11
上面qt-2.3.2是在交叉编译器arm-linux里的。
回顾一下曾经的error.在我的系统上。下面的错误的根本原因是环境变量。
/work/qt-2.3.7/lib/libqte.so: undefined reference to `QMultiLineEdit::undoAvailable(bool)'
/work/qt-2.3.7/lib/libqte.so: undefined reference to `QWSClient::connectionClosed()'
/work/qt-2.3.7/lib/libqte.so: undefined reference to `QActionGroup::selected(QAction*)'
/work/qtopia-1.7.0/lib/libqpe.so: undefined reference to `QComboBox::className() const'
/work/qt-2.3.7/lib/libqte.so: undefined reference to `QIconView::mouseButtonPressed(int, QIconViewItem*, QPoint const&)'
collect2: ld returned 1 exit status
make[1]: *** [/work/qtopia-1.7.0/bin/sysinfo] Error 1
make[1]: Leaving directory `/work/qtopia-1.7.0/src/applications/sysinfo'
make: *** [applications/sysinfo] Error 2
============================================================
ochapman@ochapman-desktop:/work/qt-2.3.7$ make sub-src
cd src/moc; make
make[1]: Entering directory `/work/qt-2.3.7/src/moc'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/work/qt-2.3.7/src/moc'
rm -f bin/moc
cp src/moc/moc bin/moc
make -f src-mt.mk
make[1]: Entering directory `/work/qt-2.3.7'
(not building threaded Qt)
make[1]: Leaving directory `/work/qt-2.3.7'
cd src; make
make[1]: Entering directory `/work/qt-2.3.7/src'
/work/qt-2.3.7/bin/moc kernel/qthread_unix.cpp -o kernel/qthread_unix.moc
/work/qt-2.3.7/bin/moc: 1: Syntax error: word unexpected (expecting ")")
make[1]: *** [kernel/qthread_unix.moc] Error 2
make[1]: Leaving directory `/work/qt-2.3.7/src'
make: *** [sub-src] Error 2
=============================================================
chapman@ochapman-desktop:/work/qtopia-1.7.0/src$ make
make -C libraries/qtopia
make[1]: Entering directory `/work/qtopia-1.7.0/src/libraries/qtopia'
/work/qt-2.3.7/bin/uic passwordbase_p.ui -o ./passwordbase_p.h
/work/qt-2.3.7/bin/uic: error while loading shared libraries: libqutil.so.1: cannot open shared object file: No such file or directory
make[1]: *** [passwordbase_p.h] Error 127
make[1]: Leaving directory `/work/qtopia-1.7.0/src/libraries/qtopia'
make: *** [libraries/qtopia] Error 2
=============================================================