• 6340阅读
  • 1回复

【新手】安装了QT,用hello QT小程序进行测试 出错 [复制链接]

上一主题 下一主题
离线lajiya4
 
只看楼主 倒序阅读 楼主  发表于: 2009-09-18
按照官网的指点,安装了QT
On Linux/Unix, you need to make the file executable in order to run it. You can either do this with your desktop's file manager or, at the command line, type:

chmod u+x qt-sdk-linux-x86-opensource-2009.03.1.bin

You should now be able to execute the file as normal. You can do this from the command line by typing:

./qt-sdk-linux-x86-opensource-2009.03.1.bin

只有在QT creator里面用以下程序测试:
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
     QApplication app(argc, argv);
     QLabel *label = new QLabel("Hello Qt!");
     label->show();
     return app.exec();
}


报错
在compile output里 信息如下:

Running build steps for project hello...
Configuration unchanged, skipping QMake step.
Starting: /usr/bin/make -w
make: Entering directory `/root/hello'
g++ -o hello hello.o main.o mainwindow.o moc_mainwindow.o -L/opt/qtsdk-2009.03/qt/lib -lqt-mt -lXext -lX11 -lm
main.o: In function `main':
/opt/qtsdk-2009.03/qt/include/QtGui/qwidget.h:473: multiple definition of `main'
hello.o:/root/hello/hello.cpp:3: first defined here
/usr/bin/ld: Warning: size of symbol `main' changed from 287 in hello.o to 184 in main.o
/usr/bin/ld: cannot find -lqt-mt
collect2: ld returned 1 exit status
make: Leaving directory `/root/hello'
make: *** [hello] Error 1
Exited with code 2.
Error while building project hello
When executing build step 'Make'

在网上查了下,说 【打开你项目文件下底下的Makefile文件,找到CFLAG:开头的这行,删除 "-lgthread-2.0",就可以了】
但我在我的makefile里面找不到lgthread-2.0

································
请问该如何解决?
离线dbzhang800

只看该作者 1楼 发表于: 2009-09-19
  1. main.o: In function `main':
  2. /opt/qtsdk-2009.03/qt/include/QtGui/qwidget.h:473: multiple definition of `main'
  3. hello.o:/root/hello/hello.cpp:3: first defined here
  4. /usr/bin/ld: Warning: size of symbol `main' changed from 287 in hello.o to 184 in main.o


你先介绍一下,你除了这个文件,工程内还有其他的什么文件。

从出错信息看,你至少有 main.cpp 和 hello.cpp 这两个文件,而且每个文件内你都定义了一个main函数!
快速回复
限100 字节
 
上一个 下一个