• 7164阅读
  • 7回复

弱智的问T ,,,,,,,大家帮一下,,,,,, [复制链接]

上一主题 下一主题
离线qhmao
 
只看楼主 倒序阅读 楼主  发表于: 2009-05-17
系统 为  ubuntu 9.04 +     qt 4.5.1     http://get.qtsoftware.com/qtsdk/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'





如果 在文件下,,,,
只有hello.c下,

qmake -project
qmake hello.pro
make

则出现:

sun@sun-desktop:~/Desktop/Myprojects/hello$ qmake hello.pro
sun@sun-desktop:~/Desktop/Myprojects/hello$ ls
hello.cpp  hello.pro  Makefile
sun@sun-desktop:~/Desktop/Myprojects/hello$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o hello.o hello.cpp
hello.cpp:1:24: error: QApplication: No such file or directory
hello.cpp:2:18: error: QLabel: No such file or directory
hello.cpp: In function ‘int main(int, char**)’:
hello.cpp:6: error: ‘QApplication’ was not declared in this scope
hello.cpp:6: error: expected `;' before ‘app’
hello.cpp:7: error: ‘QLabel’ was not declared in this scope
hello.cpp:7: error: ‘label’ was not declared in this scope
hello.cpp:7: error: expected type-specifier before ‘QLabel’
hello.cpp:7: error: expected `;' before ‘QLabel’
hello.cpp:9: error: ‘app’ was not declared in this scope
hello.cpp: At global scope:
hello.cpp:4: warning: unused parameter ‘argc’
hello.cpp:4: warning: unused parameter ‘argv’
make: *** [hello.o] Error 1

我感觉这是一个巨弱智的问T ,,可是,google上研究了半天,也没搞懂,,,,,


qmake -v 如下:
QMake version 2.01a
Using Qt version 4.5.0 in /usr/lib


export  如下:

declare -x COLORTERM="gnome-terminal"
declare -x DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-7CCVeIUruP,guid=7117e416643851b59fc5477d4a0ec063"
declare -x DESKTOP_SESSION="default"
declare -x DISPLAY=":0.0"
declare -x GDMSESSION="default"
declare -x GDM_LANG="en_US.UTF-8"
declare -x GDM_XSERVER_LOCATION="local"
declare -x GNOME_DESKTOP_SESSION_ID="this-is-deprecated"
declare -x GNOME_KEYRING_PID="2985"
declare -x GNOME_KEYRING_SOCKET="/tmp/keyring-fnL7Gd/socket"
declare -x GPG_AGENT_INFO="/tmp/seahorse-6bDBQX/S.gpg-agent:3086:1"
declare -x GTK_IM_MODULE="xim"
declare -x GTK_MODULES="canberra-gtk-module"
declare -x GTK_RC_FILES="/etc/gtk/gtkrc:/home/sun/.gtkrc-1.2-gnome2"
declare -x HISTCONTROL="ignoreboth"
declare -x HOME="/home/sun"
declare -x LANG="en_US.UTF-8"
declare -x LESSCLOSE="/usr/bin/lesspipe %s %s"
declare -x LESSOPEN="| /usr/bin/lesspipe %s"
declare -x LOGNAME="sun"
declare -x LS_COLORS="no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:"
declare -x OLDPWD="/home/sun"
declare -x ORBIT_SOCKETDIR="/tmp/orbit-sun"
declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
declare -x PWD="/home/sun/Desktop/Myprojects/hello"
declare -x QT_IM_MODULE="xim"
declare -x SESSION_MANAGER="local/sun-desktop:/tmp/.ICE-unix/2998"
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x SSH_AGENT_PID="3063"
declare -x SSH_AUTH_SOCK="/tmp/keyring-fnL7Gd/socket.ssh"
declare -x TERM="xterm"
declare -x USER="sun"
declare -x USERNAME="sun"
declare -x WINDOWID="65011766"
declare -x WINDOWPATH="7"
declare -x XAUTHORITY="/home/sun/.Xauthority"
declare -x XDG_DATA_DIRS="/usr/local/share/:/usr/share/:/usr/share/gdm/"
declare -x XDG_SESSION_COOKIE="010ef2187875526283c00a0e49fa7e1e-1242480737.49402-1507134127"
declare -x XMODIFIERS="@im=SCIM"
离线qhmao
只看该作者 1楼 发表于: 2009-05-17
Qt Creator     Tool   -->Qt4    


version Name :   Qt 4.5.1 OpenSource
path:                    /home/sun/qt/qt

Default Qt Version      Qt 4.5.1 OpenSource
离线gvim
只看该作者 2楼 发表于: 2009-05-17
1) 第一个问题,系统里没装 libfreetrype的开发库
2) 第二个问题 qmake要用SDK路径里的那个qmake.
Qt,Qt! 分享Cute之Qt体验
欢迎访问 http://www.cuteqt.com
欢迎订阅 http://www.cuteqt.com/?feed=rss2

离线qhmao
只看该作者 3楼 发表于: 2009-05-17
引用第2楼gvim于2009-05-17 09:13发表的  :
1) 第一个问题,系统里没装 libfreetrype的开发库
2) 第二个问题 qmake要用SDK路径里的那个qmake.



libfreetype-dev  装上了,,,,,,


make 时,出现以下:
/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'
离线qhmao
只看该作者 4楼 发表于: 2009-05-17
qmake要用SDK路径里的那个qmake.


这个怎么指定这个 路径呢?  、

要把那个qmake -v 如下:
QMake version 2.01a
Using Qt version 4.5.0 in /usr/lib
的删除么?

如果删除后,怎么指定到 Qt 4.5.1 OpenSource下的呢?
离线qhmao
只看该作者 5楼 发表于: 2009-05-17
4.5.0的qmake的删除了,,,,

sun@sun-desktop:~/Desktop/pro/h2$ qmake -v
QMake version 2.01a
Using Qt version 4.5.1 in /home/sun/qt/qt/lib
sun@sun-desktop:~/Desktop/pro/h2$


此时,make 出现如下错误:

/usr/bin/ld: cannot find -lgobject-2.0
collect2: ld returned 1 exit status
make: *** [hello] Error 1
sun@sun-desktop:~/Desktop/pro/h2$ qmake -v
QMake version 2.01a
Using Qt version 4.5.1 in /home/sun/qt/qt/lib
sun@sun-desktop:~/Desktop/pro/h2$
离线qhmao
只看该作者 6楼 发表于: 2009-05-17
问题已经解决  ,,,,

参考:
http://www.qtcn.org/bbs/read.php?tid=18448
离线huliyaya
只看该作者 7楼 发表于: 2009-06-03
快速回复
限100 字节
 
上一个 下一个