寻解qt4编译问题:“make: *** [main.o] 错误 1”

xbmoxia 2011-11-11 12:29:56
以下代码是我在VMware的Ubuntu11.04里编写的示例程序,但是编译时总是出现以下错误,希望有关高手能帮忙解决。

g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o main.o main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:11:9: error: no matching function for call to ‘QDebug::QDebug()’
/usr/include/qt4/QtCore/qdebug.h:79:12: note: candidates are: QDebug::QDebug(const QDebug&)
/usr/include/qt4/QtCore/qdebug.h:78:12: note: QDebug::QDebug(QtMsgType)
/usr/include/qt4/QtCore/qdebug.h:77:12: note: QDebug::QDebug(QString*)
/usr/include/qt4/QtCore/qdebug.h:76:12: note: QDebug::QDebug(QIODevice*)
make: *** [main.o] 错误 1


#include<QApplication>
#include<QString>
#include<QLabel>
#include<QWidget>
#include<QDebug>
#include<QTextStream>
int main(int argc,char *argv[])
{
QApplication myapp(argc,argv);
QWidget wid;
QDebug()<<"sizeof widget: "<<sizeof(wid)
<<"sizeof qapplication: "<<sizeof(myapp);
QString message;
QTextStream buf(&message);
buf<<"A QWdget is "<<sizeof(wid)
<<" bytes. \nA QObject is "<<sizeof(QObject)
<<" bytes. \nA QApplication is "<<sizeof(myapp)
<<" bytes.";
qDebug()<<message;
QLabel label(message);
label.show();
return myapp.exec();
};
...全文
2572 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ydscn 2012-10-15
  • 打赏
  • 举报
回复
一楼说的对,代码中的QDebug 确实应该为 qDebug
rzgreat 2012-09-25
  • 打赏
  • 举报
回复
确实正解
帅得不敢出门 2011-11-11
  • 打赏
  • 举报
回复
1楼正解
BuleRiver 2011-11-11
  • 打赏
  • 举报
回复
1L正解
typedef_me_shore 2011-11-11
  • 打赏
  • 举报
回复
你代码中的QDebug 应该为 qDebug

23,216

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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