当前位置: 技术问答>linux和unix
(求助)关于QT程序编译libqte.so: undefined reference 的问题
来源: 互联网 发布时间:2016-05-08
本文导语: 最近在学QT,配置环境就弄了好久,今天终于把PC机上的环境编译成功了,用个小程序试了一下,出现了下面的错误 [root@localhost root]# cd /root/myqt/qtexample/helloworld [root@localhost helloworld]# export QTDIR=/root/myqt/QT/qt-2.3.7 [ro...
最近在学QT,配置环境就弄了好久,今天终于把PC机上的环境编译成功了,用个小程序试了一下,出现了下面的错误
[root@localhost root]# cd /root/myqt/qtexample/helloworld
[root@localhost helloworld]# export QTDIR=/root/myqt/QT/qt-2.3.7
[root@localhost helloworld]# progen -o helloworld.pro
[root@localhost helloworld]# tmake -o Makefile helloworld.pro
[root@localhost helloworld]# make
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -fno-default-inline -DNO_DEBUG -I/root/myqt/QT/qt-2.3.7/include -o helloworld.o helloworld.cpp
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -fno-default-inline -DNO_DEBUG -I/root/myqt/QT/qt-2.3.7/include -o main.o main.cpp
g++ -o helloworld helloworld.o main.o -L/root/myqt/QT/qt-2.3.7/lib -lm -lqte
/root/myqt/QT/qt-2.3.7/lib/libqte.so: undefined reference to `QWizard::staticMetaObject()'
collect2: ld returned 1 exit status
make: *** [helloworld] Error 1
我查了些资料,有的说是环境变量的问题,有的说的编译时配置的问题,弄了好久也没太明白,现在不知道该怎么解决,请各位高手们帮帮忙,是不是我的编译过程里有些细节没注意到
我的编译过程如下,按这个过程可以编译成功:
用了下面的文件:
qtopia-free-1.7.0.tar.gz
qt-embedded-2.3.7.tar.gz
qt-x11-2.3.2.tar.gz
e2fsprogs-1.40.2.tar.gz
tmake-1.13.tar.gz
五个包放在一个文件夹里/root/myqt/QT
tar zxvf tmake-1.13.tar.gz
tar zxvf qtopia-free-1.7.0.tar.gz
tar zxvf tmake-1.13.tar.gz
tar zxvf qt-embedded-2.3.10-free.tar.gz
tar zxvf qt-x11-2.3.2.tar.gz
vi /setqt.sh
下面是shell文件的具体内容:
TMAKEDIR=/root/myqt/QT/tmake-1.13
QT2DIR=/root/myqt/QT/qt-2.3.2
QTEDIR=/root/myqt/QT/qt-2.3.7
QPEDIR=/root/myqt/QT/qtopia-free-1.7.0
QT3DIR=/usr/lib/qt-3.1
QTDIR=$QTEDIR
DQTDIR=$QT3DIR
TMAKEPATH=$TMAKEDIR/lib/qws/linux-x86-g++
QMAKESPEC=linux-g++
PATH=$QT2DIR/bin:$QTEDIR/bin:$QPEDIR/bin:$DQTDIR/bin:$QT3DIR/bin:$QT2DIR/bin:$TMAKEDIR/bin:$PATH LD_LIBRARY_PATH=$QT2DIR/lib:$QTEDIR/lib:$QPEDIR/lib:$DQTDIR/lib:$QT3DIR/lib:$QTDIR/lib:$LD_LIBRARY_PATH export TMAKEDIR QT2DIR QTEDIR QPEDIR QT3DIR QTDIR DQTDIR TMAKEPATH QMAKESPEC PATH LD_LIBRARY_PATH
source /setqt.sh
编译QT/Embedded:
cd qt-2.3.7
cp $QPEDIR/src/qt/qconfig-qpe.h src/tools/
./configure -system-jpeg -gif -no-xft -thread -qconfig qpe -qvfb -depths 4,8,16,32
make sub-src
cd ..
编译QT/X11:
cd $QT2DIR
export QTDIR=$PWD
./configure -no-xft
make sub-src
cd tools/designer/util
make
cd ../uic
make
cd ../../..
make -C tools/qvfb
cp tools/qvfb/qvfb $QT2DIR/bin
cp $QTDIR/bin/uic $QTEDIR/bin
cd tools
make
cd ..
编译e2fsprogs:
cd e2fsprogs-1.40.2
cp -r lib/uuid ../qtopia-free-1.7.0/include
export PATH=$PWD/bin:$PATH
./configure --enable-elf-shlibs
make
cp lib/libuuid.so* ../qt-2.3.7/lib
cd ..
编译qtopia:
cd $QPEDIR
export QTDIR=$QTEDIR
cd src
./configure -system-jpeg -gif -thread
make
cd ..
export QTDIR=/root/myqt/QT/qt-2.3.7
export QPEDIR=/root/myqt/QT/qtopia-free-1.7.0
[root@localhost root]# cd /root/myqt/qtexample/helloworld
[root@localhost helloworld]# export QTDIR=/root/myqt/QT/qt-2.3.7
[root@localhost helloworld]# progen -o helloworld.pro
[root@localhost helloworld]# tmake -o Makefile helloworld.pro
[root@localhost helloworld]# make
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -fno-default-inline -DNO_DEBUG -I/root/myqt/QT/qt-2.3.7/include -o helloworld.o helloworld.cpp
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -fno-default-inline -DNO_DEBUG -I/root/myqt/QT/qt-2.3.7/include -o main.o main.cpp
g++ -o helloworld helloworld.o main.o -L/root/myqt/QT/qt-2.3.7/lib -lm -lqte
/root/myqt/QT/qt-2.3.7/lib/libqte.so: undefined reference to `QWizard::staticMetaObject()'
collect2: ld returned 1 exit status
make: *** [helloworld] Error 1
我查了些资料,有的说是环境变量的问题,有的说的编译时配置的问题,弄了好久也没太明白,现在不知道该怎么解决,请各位高手们帮帮忙,是不是我的编译过程里有些细节没注意到
我的编译过程如下,按这个过程可以编译成功:
用了下面的文件:
qtopia-free-1.7.0.tar.gz
qt-embedded-2.3.7.tar.gz
qt-x11-2.3.2.tar.gz
e2fsprogs-1.40.2.tar.gz
tmake-1.13.tar.gz
五个包放在一个文件夹里/root/myqt/QT
tar zxvf tmake-1.13.tar.gz
tar zxvf qtopia-free-1.7.0.tar.gz
tar zxvf tmake-1.13.tar.gz
tar zxvf qt-embedded-2.3.10-free.tar.gz
tar zxvf qt-x11-2.3.2.tar.gz
vi /setqt.sh
下面是shell文件的具体内容:
TMAKEDIR=/root/myqt/QT/tmake-1.13
QT2DIR=/root/myqt/QT/qt-2.3.2
QTEDIR=/root/myqt/QT/qt-2.3.7
QPEDIR=/root/myqt/QT/qtopia-free-1.7.0
QT3DIR=/usr/lib/qt-3.1
QTDIR=$QTEDIR
DQTDIR=$QT3DIR
TMAKEPATH=$TMAKEDIR/lib/qws/linux-x86-g++
QMAKESPEC=linux-g++
PATH=$QT2DIR/bin:$QTEDIR/bin:$QPEDIR/bin:$DQTDIR/bin:$QT3DIR/bin:$QT2DIR/bin:$TMAKEDIR/bin:$PATH LD_LIBRARY_PATH=$QT2DIR/lib:$QTEDIR/lib:$QPEDIR/lib:$DQTDIR/lib:$QT3DIR/lib:$QTDIR/lib:$LD_LIBRARY_PATH export TMAKEDIR QT2DIR QTEDIR QPEDIR QT3DIR QTDIR DQTDIR TMAKEPATH QMAKESPEC PATH LD_LIBRARY_PATH
source /setqt.sh
编译QT/Embedded:
cd qt-2.3.7
cp $QPEDIR/src/qt/qconfig-qpe.h src/tools/
./configure -system-jpeg -gif -no-xft -thread -qconfig qpe -qvfb -depths 4,8,16,32
make sub-src
cd ..
编译QT/X11:
cd $QT2DIR
export QTDIR=$PWD
./configure -no-xft
make sub-src
cd tools/designer/util
make
cd ../uic
make
cd ../../..
make -C tools/qvfb
cp tools/qvfb/qvfb $QT2DIR/bin
cp $QTDIR/bin/uic $QTEDIR/bin
cd tools
make
cd ..
编译e2fsprogs:
cd e2fsprogs-1.40.2
cp -r lib/uuid ../qtopia-free-1.7.0/include
export PATH=$PWD/bin:$PATH
./configure --enable-elf-shlibs
make
cp lib/libuuid.so* ../qt-2.3.7/lib
cd ..
编译qtopia:
cd $QPEDIR
export QTDIR=$QTEDIR
cd src
./configure -system-jpeg -gif -thread
make
cd ..
export QTDIR=/root/myqt/QT/qt-2.3.7
export QPEDIR=/root/myqt/QT/qtopia-free-1.7.0
|
应该是编译环境没搭好吧,你看看当时你的configure后面的参数,还有QT/E2.3.7库是不是6.2M?