标题:运行一个简单的hello程序报错 ,请大家帮忙看看
作者:ypp421
日期:2009-03-12 22:47
内容:
Makefile:120: warning: overriding commands for target `moc_hello.cpp'
Makefile:117: warning: ignoring old commands for target `moc_hello.cpp'
arm-linux-g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/opt/qt-2.3.7/include -o main.o main.cpp
main.cpp: In function `int main(int, char**)':
main.cpp:9: error: parse error before `(' token
make: *** Error 1
#include "qwidget.h"
#include "hello.h"
#include
int main(int argc,char **argv)
{
QApplication app(argc,argv);
Hello *hello=new Form1();
hello->show();
app.setMainWidget(hello);
return(app.exec());
}
上面是main程序,应该是没有错的。这个程序就是用designer生成一个Form1。hello.hhello.cpp都是没有修改的。总是感觉是不是连接出问题阿!
请各位热爱linux的朋友们帮忙看看。不胜感谢
#1 [浪漫天使 03-13 08:07]
Hello *hello=new Form1(); 这句有点牛头对马嘴的感觉。。。。
#2 QT链接总是出错::求助 [ypp421 03-13 18:31]
In file included from hello.cpp:9:
hello.h:12:22: error: qvariant.h: No such file or directory
hello.h:13:21: error: qdialog.h: No such file or directory
hello.cpp:11:25: error: qpushbutton.h: No such file or directory
hello.cpp:12:21: error: qlayout.h: No such file or directory
hello.cpp:14:22: error: qtooltip.h: No such file or directory
hello.cpp:15:24: error: qwhatsthis.h: No such file or directory
In file included from hello.cpp:9:
hello.h:20: error: expected class-name before '{' token
hello.h:21: error: ISO C++ forbids declaration of 'Q_OBJECT' with no type
hello.h:23: error: expected ';' before 'public'
hello.cpp:24: error: expected `)' before '*' token
在Makefile中,设置如下:
QTDIR = /usr
CC= gcc
CXX = g++
CFLAGS= -pipe -Wall -W -DNO_DEBUG
CXXFLAGS= -pipe -Wall -W -DNO_DEBUG
INCPATH = -I$(QTDIR)/include/qt
LINK= g++
LFLAGS=
LIBS= $(SUBLIBS) -L$(QTDIR)/lib -L/usr/X11R6/lib -lqt -lXext -lX11 -lm
MOC = $(QTDIR)/bin/moc
UIC = $(QTDIR)/bin/uic
应该是LIBS出错可是不知道怎么改成可以链接QT库(注明不是交叉编译)
#3 [浪漫天使 03-13 18:43]
QTDIR = /usr???
这个是你写上去的??
#4 [shaoshuai_49 03-13 19:01]
hello.h:12:22: error: qvariant.h: No such file or directory是找不到头文件的问题啊
#5 [ypp421 03-18 09:15]
我的QTDIR不是/usr在命令行模式下是对的可不知道为什么在这里会显示为/usr难道是因为这里而链接不上吗 呵呵谢谢楼上的帮忙分析了