标题:一个让我无比郁闷的初级问题
作者:fkwcowboy
日期:2006-06-01 19:16
内容:
这是我执行hello程序时候出现的问题 程序指定没问题- - 照书打的 哪位知道怎么回事?
# cd /root/qt
# qmake
# make
g++ -c -pipe -Wall -W -O2 -g -pipe -march=i386 -mcpu=i686 -fno-use-cxa-atexit -fno-exceptions -DQT_NO_DEBUG -I/usr/lib/qt-3.1/mkspecs/default -I. -I/usr/lib/qt-3.1/include -I.ui/ -I.moc/ -o .obj/hello.o hello.cpp
hello.cpp:1:24: QApplication: 没有那个文件或目录
hello.cpp:2:23: QPushButton: 没有那个文件或目录
hello.cpp: In function `int main(int, char**)':
hello.cpp:5: error: `QApplication' undeclared (first use this function)
hello.cpp:5: error: (Each undeclared identifier is reported only once for each
function it appears in.)
hello.cpp:5: error: syntax error before `(' token
hello.cpp:6: error: `QPushButton' undeclared (first use this function)
hello.cpp:7: error: `hello' undeclared (first use this function)
hello.cpp:9: error: `app' undeclared (first use this function)
hello.cpp:4: warning: unused parameter `int argc'
hello.cpp:4: warning: unused parameter `char**argv'
#1 [zhaonash 06-01 19:55]
之前应该要export QTDIR=/和 LD_LIBRARY_PATH吧
#2 [guyansrg 06-01 19:59]
你好像用的是qt-3.1,没看代码,不知道你打开的hello程序代码是适用于Qt3还是Qt4
#3 [cocalele 06-01 22:01]
好像qt3里面使用 #include 这种风格
qt4使用#include 这种风格。你的程序是照qt4的书抄的吧,而你的机器上装的是qt3,就会有现在的问题
#4 [henryhome 06-02 00:23]
hello.cpp:2:23: QPushButton: 没有那个文件或目录 在头文件(*.h)中定义并在主程序(*.cpp)开头加载该头文件
hello.cpp:4: warning: unused parameter `int argc' 程序中只是定义了但并没用到,不影响正常运行
#5 [fkwcowboy 06-02 11:09]
我电脑里装了连个版本的QT啊
也有QT4啊~
我从网上DOWN的QT4程序就可以编译啊- - 哪位在给点详细的解答啊