sudo apt-get install build-essential
tar -zxvf qt-x11-opensource-src-4.5.3.tar.gz
./configure
配置过程出错了:
Basic XLib functionality test failed!
You might need to modify the include and library search paths by editing
QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11 in /tmp/qt-x11-opensource-src-4.5.3/mkspecs/linux-g++.
解决方法:
#sudo apt-get install libx11-dev libfreetype6-dev libavahi-gobject-dev libSM-dev libXrender-dev libfontconfig-dev libXext-dev
之后重新配置。
make
make install
# vi ~/.bashrc
QTDIR=/usr/local/Trolltech/Qt-4.5.3/
PATH=$QTDIR/bin:$PATH
MANPATH=$QTDIR/doc/man:$MANPATH
LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export QTDIR PATH MANPATH LD_LIBRARY_PATH
测试QT环境:
mkdir hello
编写hello.cpp
#include
#include
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QPushButton hello( "Hello world!");
hello.resize( 100, 30 );
hello.show();
return a.exec();
}
编译:
qmake -project
qmake
make
生成可执行程序hello
运行:
./hello
阅读(1760) | 评论(0) | 转发(0) |