Ubuntu 9.04 + Qt 4.5.1 安装加运行Hello Qt!!!!!!说明

软件和网站开发以及相关技术探讨
回复
qhmao
帖子: 5
注册时间: 2007-04-23 16:29

Ubuntu 9.04 + Qt 4.5.1 安装加运行Hello Qt!!!!!!说明

#1

帖子 qhmao » 2009-05-17 20:49

安装:
http://get.qtsoftware.com/qtsdk/qt-sdk- ... 009.02.bin

下载地址:
http://www.qtsoftware.com/downloads/sdk ... -32bit-cpp

chmod u+x qt-sdk-linux-x86-opensource-2009.02.bin
./qt-sdk-linux-x86-opensource-2009.02.bin
接着出现安装,,,,,





安装结束,,,,,
运行如下代码时
#include <QApplication>
#include <QLabel>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt!");
label->show();
return app.exec();
}


Qt Creator 编译运行,,,
Starting: /usr/bin/make -w
make: Entering directory `/home/sun/Desktop/Myprojects/hello'
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../qt/qt/mkspecs/linux-g++ -I. -I../../../qt/qt/include/QtCore -I../../../qt/qt/include/QtGui -I../../../qt/qt/include -I. -I. -I. -o hello.o hello.cpp
g++ -Wl,-O1 -Wl,-rpath,/home/sun/qt/qt/lib -o hello hello.o -L/home/sun/qt/qt/lib -lQtGui -L/home/sun/qt/qt/lib -L/usr/X11R6/lib -pthread -lfreetype -lgobject-2.0 -lSM -lICE -pthread -pthread -lXrender -lfontconfig -lXext -lX11 -lQtCore -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread
/usr/bin/ld: cannot find -lfreetype
collect2: ld returned 1 exit status
make: *** [hello] Error 1
make: Leaving directory `/home/sun/Desktop/Myprojects/hello'
Exited with code 2.
Error while building project hello
When executing build step 'Make'

解决 /usr/bin/ld: cannot find -lfreetype

安装 libfreetype-dev
(用synaptic Package Manager 选 libfreetype6 和libfreetype6-dev )



编译时出现:
/usr/bin/ld: cannot find -lgobject-2.0
collect2: ld returned 1 exit status
make: *** [hello] Error 1
make: Leaving directory `/home/sun/Desktop/pro/hello'
Exited with code 2.
Error while building project hello
When executing build step 'Make'


安装:
gob2 2.0.15-1

libsm6
libsm-dev
libxrender-dev
fontconfig-dev
libxetx-dev


此时即可解决,,,,,,
编译、运行正常,,,
安装文件参考原英文帖子:
http://stackoverflow.com/questions/6462 ... -qt/865945


说明:
昨晚折腾到1点多,还未解决问题,,,,
刚关机,想到了环境变量未设置,开机设置,问题仍在,,,,,

早上6点就爬起来,继续,,,,

多谢gvim兄的帮助,,,,,,
问题原帖子: http://www.qtcn.org/bbs/read.php?tid=18439



原地址: http://www.qtcn.org/bbs/read.php?tid=18448

---------------------昨晚搜索问题时,见坛里也有类似问题,一并发过来,有的兄弟可能用得着。。。。。。。
头像
lukewoo
帖子: 2
注册时间: 2007-08-07 9:52

Re: Ubuntu 9.04 + Qt 4.5.1 安装加运行Hello Qt!!!!!!说明

#2

帖子 lukewoo » 2009-05-25 10:55

我下载了qt-sdk-linux-x86-opensource-2009.02.bin
照着官方网站上的安装说明安装的,
执行./qt-sdk-linux-x86-opensource-2009.02.bin
是显示:段错误

这是怎么回事呢? :em20
qhmao
帖子: 5
注册时间: 2007-04-23 16:29

Re: Ubuntu 9.04 + Qt 4.5.1 安装加运行Hello Qt!!!!!!说明

#3

帖子 qhmao » 2009-05-27 11:38

lukewoo 写了:我下载了qt-sdk-linux-x86-opensource-2009.02.bin
照着官方网站上的安装说明安装的,
执行./qt-sdk-linux-x86-opensource-2009.02.bin
是显示:段错误

这是怎么回事呢? :em20

我当时是用xp 下的迅雷下载转至U盘,安装时也出现了错误,,,,,

在ubuntu 下用FF下载后,安装即正确,,,,,,
头像
xnnyygn
帖子: 64
注册时间: 2009-05-29 15:14

Re: Ubuntu 9.04 + Qt 4.5.1 安装加运行Hello Qt!!!!!!说明

#4

帖子 xnnyygn » 2009-05-31 0:06

也就是说只要安装libfreetype-dev和libgtk2-dev就可以了
咱自己尝试了一下可以的
Grails&Qt With Linux
头像
wangdu2002
帖子: 13284
注册时间: 2008-12-13 19:39
来自: 物华天宝人杰地灵

Re: Ubuntu 9.04 + Qt 4.5.1 安装加运行Hello Qt!!!!!!说明

#5

帖子 wangdu2002 » 2009-05-31 1:10

楼主辛苦了。我正在学习Qt,用得着,感谢之。 :em11
行到水穷处,坐看云起时。
海内生明月,天涯共此夕。
--------------------吾本独!
回复