• 4722阅读
  • 6回复

运行一个简单的hello程序报错 ,请大家帮忙看看 [复制链接]

上一主题 下一主题
离线ypp421
 
只看楼主 倒序阅读 楼主  发表于: 2009-03-12
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: *** [main.o] Error 1


#include "qwidget.h"
#include "hello.h"
#include <qapplication.h>

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.h  hello.cpp都是没有修改的。总是感觉是不是连接出问题阿!
请各位热爱linux的朋友们帮忙看看。不胜感谢
离线浪漫天使
只看该作者 1楼 发表于: 2009-03-13
Hello *hello=new Form1(); 这句有点牛头对马嘴的感觉。。。。
离线ypp421
只看该作者 2楼 发表于: 2009-03-13
QT链接总是出错::求助
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楼 发表于: 2009-03-13
QTDIR   =       /usr???
这个是你写上去的??
离线shaoshuai_49
只看该作者 4楼 发表于: 2009-03-13
hello.h:12:22: error: qvariant.h: No such file or directory  是找不到头文件的问题啊  
离线ypp421
只看该作者 5楼 发表于: 2009-03-18
我的QTDIR不是/usr  在命令行模式下是对的  可不知道为什么在这里会显示为/usr  难道是因为这里而链接不上吗   呵呵  谢谢楼上的帮忙分析了
离线hanvy.xia
只看该作者 6楼 发表于: 2009-03-18
Hello *hello=new Form1();
to
      Hello *hello=new Hello();
or
     Form1 *hello=new Form1();
快速回复
限100 字节
 
上一个 下一个