我是新手,我在make时出现这些错误,请大侠帮帮忙

lannier2008 2009-09-14 03:36:42
[root@localhost root]# cd mywork
[root@localhost mywork]# ls
lily.cpp lily.h lily.pro lily.ui main.cpp Makefile
[root@localhost mywork]# make
Makefile:120: warning: overriding commands for target `moc_lily.cpp'
Makefile:117: warning: ignoring old commands for target `moc_lily.cpp'
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/root/qt/include -o lily.o lily.cpp
In file included from lily.cpp:10:
lily.h:13:22: qvariant.h: 没有那个文件或目录
lily.h:14:21: qwidget.h: 没有那个文件或目录
In file included from lily.cpp:10:
lily.h:22: parse error before `{' token
lily.h:27: destructors must be member functions
lily.h:31: parse error before `protected'
lily.cpp:12:22: qvariant.h: 没有那个文件或目录
lily.cpp:13:25: qpushbutton.h: 没有那个文件或目录
lily.cpp:14:21: qlayout.h: 没有那个文件或目录
lily.cpp:15:22: qtooltip.h: 没有那个文件或目录
lily.cpp:16:24: qwhatsthis.h: 没有那个文件或目录
lily.cpp:22: `QWidget' was not declared in this scope
lily.cpp:22: `parent' was not declared in this scope
lily.cpp:22: parse error before `char'
lily.cpp:23: invalid use of undefined type `class test'
lily.h:21: forward declaration of `class test'
lily.cpp: In constructor `test::test(...)':
lily.cpp:23: `parent' undeclared (first use this function)
lily.cpp:23: (Each undeclared identifier is reported only once for each
function it appears in.)
lily.cpp:23: `name' undeclared (first use this function)
lily.cpp:23: `fl' undeclared (first use this function)
lily.cpp:23: class `test' does not have any field named `QWidget'
lily.cpp:26: `setName' undeclared (first use this function)
lily.cpp:28: invalid use of undefined type `struct QPushButton'
lily.h:19: forward declaration of `struct QPushButton'
lily.cpp:29: `QRect' undeclared (first use this function)
lily.cpp:30: `languageChange' undeclared (first use this function)
lily.cpp:31: `QSize' undeclared (first use this function)
lily.cpp:31: `minimumSizeHint' undeclared (first use this function)
lily.cpp:31: `resize' undeclared (first use this function)
lily.cpp: At global scope:
lily.cpp:38: invalid use of undefined type `class test'
lily.h:21: forward declaration of `class test'
lily.cpp:47: invalid use of undefined type `class test'
lily.h:21: forward declaration of `class test'
lily.cpp: In member function `void test::languageChange()':
lily.cpp:48: `tr' undeclared (first use this function)
lily.cpp:48: `setCaption' undeclared (first use this function)
make: *** [lily.o] Error 1
[root@localhost mywork]# echo $TMAKEPATH
/root/tmakepath
[root@localhost mywork]# echo $QTDIR
/root/qt
[root@localhost mywork]# echo $LD_LIBRARY_PATH
/root/qt/lib
[root@localhost mywork]#
...全文
488 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xujinhui197 2010-04-26
  • 打赏
  • 举报
回复
自动生成的,肯定已经加了!
再检查一下你的makefile!
估计是你的libs搞错了
fox000002 2010-04-26
  • 打赏
  • 举报
回复
lz 用的是 QT4 吧

qwidget.h 应该是 QT3 和以前版本的头文件

如果用 QT4 编译 QT3 代码需要定义

#define QT3_SUPPORT
lannier2008 2009-09-14
  • 打赏
  • 举报
回复
我按大侠的意思把对应的头文件加进来,还是提示同样的错误啊

[root@localhost root]# cd mywork
[root@localhost mywork]# ls
1.doc lily.cpp lily.h lily.pro lily.ui main.cpp Makefile moc_lily.cpp
[root@localhost mywork]# g++ -I$QTDIR/include qvariant.h qwidget.h lily.cpp main.cpp moc_lily.cpp
g++: qvariant.h: 没有那个文件或目录
g++: qwidget.h: 没有那个文件或目录
In file included from lily.cpp:10:
lily.h:13:22: qvariant.h: 没有那个文件或目录
lily.h:14:21: qwidget.h: 没有那个文件或目录
In file included from lily.cpp:10:
lily.h:22: parse error before `{' token
lily.h:27: destructors must be member functions
lily.h:31: parse error before `protected'
lily.cpp:12:22: qvariant.h: 没有那个文件或目录
lily.cpp:13:25: qpushbutton.h: 没有那个文件或目录
lily.cpp:14:21: qlayout.h: 没有那个文件或目录
lily.cpp:15:22: qtooltip.h: 没有那个文件或目录
lily.cpp:16:24: qwhatsthis.h: 没有那个文件或目录
lily.cpp:22: `QWidget' was not declared in this scope
lily.cpp:22: `parent' was not declared in this scope
lily.cpp:22: parse error before `char'
lily.cpp:23: invalid use of undefined type `class test'
lily.h:21: forward declaration of `class test'
lily.cpp: In constructor `test::test(...)':
lily.cpp:23: `parent' undeclared (first use this function)
lily.cpp:23: (Each undeclared identifier is reported only once for each
function it appears in.)
lily.cpp:23: `name' undeclared (first use this function)
lily.cpp:23: `fl' undeclared (first use this function)
lily.cpp:23: class `test' does not have any field named `QWidget'
lily.cpp:26: `setName' undeclared (first use this function)
lily.cpp:28: invalid use of undefined type `struct QPushButton'
lily.h:19: forward declaration of `struct QPushButton'
lily.cpp:29: `QRect' undeclared (first use this function)
lily.cpp:30: `languageChange' undeclared (first use this function)
lily.cpp:31: `QSize' undeclared (first use this function)
lily.cpp:31: `minimumSizeHint' undeclared (first use this function)
lily.cpp:31: `resize' undeclared (first use this function)
lily.cpp: At global scope:
lily.cpp:38: invalid use of undefined type `class test'
lily.h:21: forward declaration of `class test'
lily.cpp:47: invalid use of undefined type `class test'
lily.h:21: forward declaration of `class test'
lily.cpp: In member function `void test::languageChange()':
lily.cpp:48: `tr' undeclared (first use this function)
lily.cpp:48: `setCaption' undeclared (first use this function)
main.cpp:1:26: qapplication.h: 没有那个文件或目录
In file included from main.cpp:2:
lily.h:13:22: qvariant.h: 没有那个文件或目录
lily.h:14:21: qwidget.h: 没有那个文件或目录
In file included from main.cpp:2:
lily.h:22: parse error before `{' token
lily.h:27: destructors must be member functions
lily.h:31: parse error before `protected'
main.cpp: In function `int main(int, char**)':
main.cpp:6: `QApplication' undeclared (first use this function)
main.cpp:6: (Each undeclared identifier is reported only once for each function
it appears in.)
main.cpp:6: parse error before `(' token
main.cpp:7: `test' undeclared (first use this function)
main.cpp:8: `dlg' undeclared (first use this function)
main.cpp:9: `a' undeclared (first use this function)
main.cpp:10:2: warning: no newline at end of file
In file included from moc_lily.cpp:8:
lily.h:13:22: qvariant.h: 没有那个文件或目录
lily.h:14:21: qwidget.h: 没有那个文件或目录
In file included from moc_lily.cpp:8:
lily.h:22: parse error before `{' token
lily.h:27: destructors must be member functions
lily.h:31: parse error before `protected'
moc_lily.cpp:9:25: qmetaobject.h: 没有那个文件或目录
moc_lily.cpp:10:26: qapplication.h: 没有那个文件或目录
moc_lily.cpp:12:34: private/qucomextra_p.h: 没有那个文件或目录
moc_lily.cpp:14:2: #error "This file was generated using the moc from 3.1.1. It"moc_lily.cpp:15:2: #error "cannot be used with the include files from this version of Qt."
moc_lily.cpp:16:2: #error "(The moc has changed too much.)"
moc_lily.cpp:20: invalid use of undefined type `class test'
lily.h:21: forward declaration of `class test'
moc_lily.cpp:24: syntax error before `*' token
moc_lily.cpp:25: syntax error before `(' token
moc_lily.cpp:28: syntax error before `::' token
moc_lily.cpp:36: syntax error before `::' token
moc_lily.cpp:47: syntax error before `*' token
moc_lily.cpp:51: syntax error before `*' token
moc_lily.cpp:52: syntax error before `=' token
moc_lily.cpp:53: syntax error before `[' token
moc_lily.cpp:56: ISO C++ forbids declaration of `metaObj' with no type
moc_lily.cpp:56: `QMetaObject' was not declared in this scope
moc_lily.cpp:56: parse error before `::' token
moc_lily.cpp:65: syntax error before `.' token
moc_lily.cpp:70: invalid use of undefined type `class test'
lily.h:21: forward declaration of `class test'
moc_lily.cpp: In member function `void* test::qt_cast(const char*)':
moc_lily.cpp:71: `qstrcmp' undeclared (first use this function)
moc_lily.cpp:71: (Each undeclared identifier is reported only once for each
function it appears in.)
moc_lily.cpp:73: `QWidget' undeclared (first use this function)
moc_lily.cpp:73: parse error before `::' token
moc_lily.cpp: At global scope:
moc_lily.cpp:76: type specifier omitted for parameter `QUObject'
moc_lily.cpp:76: parse error before `*' token
moc_lily.cpp:77: invalid use of undefined type `class test'
lily.h:21: forward declaration of `class test'
moc_lily.cpp: In member function `bool test::qt_invoke(...)':
moc_lily.cpp:78: `_id' undeclared (first use this function)
moc_lily.cpp:78: `staticMetaObject' undeclared (first use this function)
moc_lily.cpp:79: `languageChange' undeclared (first use this function)
moc_lily.cpp:81: parse error before `::' token
moc_lily.cpp:83: `TRUE' undeclared (first use this function)
moc_lily.cpp: At global scope:
moc_lily.cpp:86: type specifier omitted for parameter `QUObject'
moc_lily.cpp:86: parse error before `*' token
moc_lily.cpp:87: invalid use of undefined type `class test'
lily.h:21: forward declaration of `class test'
moc_lily.cpp: In member function `bool test::qt_emit(...)':
moc_lily.cpp:88: parse error before `::' token
moc_lily.cpp: At global scope:
moc_lily.cpp:92: type specifier omitted for parameter `QVariant'
moc_lily.cpp:92: parse error before `*' token
moc_lily.cpp:93: invalid use of undefined type `class test'
lily.h:21: forward declaration of `class test'
moc_lily.cpp: In member function `bool test::qt_property(...)':
moc_lily.cpp:94: parse error before `::' token
moc_lily.cpp: At global scope:
moc_lily.cpp:97: `QObject' was not declared in this scope
moc_lily.cpp:97: parse error before `,' token
moc_lily.cpp:97: invalid use of undefined type `class test'
lily.h:21: forward declaration of `class test'
moc_lily.cpp: In member function `bool test::qt_static_property(...)':
moc_lily.cpp:97: `FALSE' undeclared (first use this function)
[root@localhost mywork]#
jiayucunyan 2009-09-14
  • 打赏
  • 举报
回复
把 -i 选项加上,后面跟上你要包含的头文件
kobemouse 2009-09-14
  • 打赏
  • 举报
回复
在lily.h中include了qvariant.h, qwidget.h等几个文件,但是编译系统没有找到该文件。编译系统将在如下几个目录查找所需include的文件:
1) 执行make命令的当前目录
2) g++中-I选项后所指定的目录
3) 系统目录,既PATH环境变量设置的目录

你应该找到qvariant.h, qwidget.h所在目录,使用-I选项将其加入到搜索目录中。
lzy0001sl 2009-09-14
  • 打赏
  • 举报
回复
"lily.h:13:22: qvariant.h: 没有那个文件或目录"
应该是缺少头文件。
make是在1977年在贝尔实验室(Bell Labs)研发的 Unix系统中的一款依赖关系检查工具程序(Utility software)。make的应用非常广泛,它被用来构建 C、C++ 、Pascal  Fortran 等项目,自动化构建生成可执行文件或者库文件。make通过读取Makefile文件以自动化建构软件, 它会根据依赖文件的修改间进行判断。确定一个target的依赖关系,然后把生成这个target的相关命令传给shell去执行。GNU make 和大多数版本的 make 之间最重要的区别是 GNU make 是自由软件,常和GNU编译系统一起被使用,是大多数GNU Linux安装的一部分。GNU makemakefile 中具有许多强大的功能,超出了其他 make 版本的功能,它还可以重新生成、使用、然后删除不需要保存的中间文件。GNU make 还有一些非常方便的简单功能。例如,选项“假装源文件文件没有更改,即使它已更改。当您向头文件添加新宏,这非常有用。大多数版本的 make 都会假设它们必须重新编译所有使用头文件的源文件,但是如果您知道对头文件的更改不需要重新编译 GNU make 为您提供了一种避免重新编译的方法-o file 。 黄强老师针对零编程基础的同学,精心打磨make核心知识点,帮助你快速掌握Linux编程中的make的构建!适用人群: 零基础、新手、想快速学习Linux下C、C++编程的童鞋!

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧