- 论坛徽章:
- 0
|
hello.cpp程序如下:
#include <qapplication.h>
#include <qlabel.h>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello, Qt!", 0);
label->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
label->setGeometry(10, 10, 200, 80);
app.setMainWidget(label);
label->show();
int result = app.exec();
return result;
}
~
编译时错误如下:
[root@localhost hell]# make
gcc -o hello hello.o
hello.o: In function `main':
hello.cpp .text+0x31): undefined reference to `QApplication: Application(int&, char**)'
hello.cpp .text+0x41): undefined reference to `QString: String(char const*)'
hello.cpp .text+0x4d): undefined reference to `operator new(unsigned int)'
hello.cpp .text+0x73): undefined reference to `QLabel: Label(QString const&, QWidget*, char const*, unsigned int)'
hello.cpp .text+0x8d): undefined reference to `QString::shared_null'
hello.cpp .text+0x99): undefined reference to `QString::shared_null'
hello.cpp .text+0xa1): undefined reference to `QStringData::deleteSelf()'
hello.cpp .text+0xeb): undefined reference to `QApplication::setMainWidget(QWidget*)'
hello.cpp .text+0xfe): undefined reference to `QApplication::exec()'
hello.cpp .text+0x10 : undefined reference to `QApplication::~QApplication()'
collect2: ld returned 1 exit status
make: *** [hello] Error 1 |
|