当前位置: 代码迷 >> QT开发 >> 寻解qt4编译有关问题:“make: * [main.o] 异常 1”
  详细解决方案

寻解qt4编译有关问题:“make: * [main.o] 异常 1”

热度:482   发布时间:2016-04-25 04:37:33.0
寻解qt4编译问题:“make: *** [main.o] 错误 1”
以下代码是我在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();
};

------解决方案--------------------
C/C++ code
#include<QApplication>#include<QString>#include<QLabel>#include<QWidget>#include<QDebug>#include<QTextStream>int main(int argc,char *argv[]){QApplication myapp(argc,argv);QWidget wid;[color=#FF0000]QDebug()[/color]<<"sizeof widget: "<<sizeof(wid)  //[color=#FF0000]qDebug()不是QDebug()[/color]<<"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();};
------解决方案--------------------
C/C++ code
qDebug()<<"sizeof widget: "<<sizeof(wid);
  相关解决方案