• 4751阅读
  • 2回复

用qt4编译程序出现错误 [复制链接]

上一主题 下一主题
离线scarlett
 
只看楼主 倒序阅读 楼主  发表于: 2010-04-09
在KDEVELOP 中编译QT4程序出现
cd '/home/scarlett/Project/hello' && LC_MESSAGES="C" LC_CTYPE="C" gmake -k
cd src/ && gmake -f Makefile
正在编译 main.cpp (g++)
正在连接 ../bin/hello (g++)
main.o: In function `main':
/home/scarlett/Project/hello/src/main.cpp:32: undefined reference to `QPushButton::QPushButton(QString const&, QWidget*)'
main.o: In function `QWidget::resize(int, int)':
/usr/include/QtGui/qwidget.h:996: undefined reference to `QWidget::resize(QSize const&)'
main.o: In function `main':
/home/scarlett/Project/hello/src/main.cpp:34: undefined reference to `QPushButton::setFlat(bool)'
/home/scarlett/Project/hello/src/main.cpp:37: undefined reference to `QPushButton::~QPushButton()'
/home/scarlett/Project/hello/src/main.cpp:37: undefined reference to `QPushButton::~QPushButton()'
collect2: ld returned 1 exit status
gmake[1]: *** [../bin/hello] Error 1
gmake[1]: Target `first' not remade because of errors.
gmake: *** [sub-src-make_default] Error 2
gmake: Target `first' not remade because of errors.
*** 退出状态:2 ***

源代码为

#include<QtCore/QTextCodec>
#include <QCoreApplication>
#include<QtGui/QPushButton>
#include<QtGui/QApplication>


int main(int argc, char *argv[])
{
      QCoreApplication app(argc, argv);
      QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));
      qDebug("Hello from Qt 4!");
      QPushButton button("Hello world",NULL);
      button.resize(400,300);
      button.setFlat(true);
     QObject::connect(&button,SIGNAL(clicked()),&app,SLOT(quit()));
button.show();
      return app.exec();
}

这是为什么,怎么办啊??大神们帮帮忙吧。。
离线yangfanxing
只看该作者 1楼 发表于: 2010-04-09
Linux?设置环境变量什么的;
没搭建好环境~
PHPWind好恶心。。。不想看这种界面。。。
离线wd007

只看该作者 2楼 发表于: 2010-04-09
没错,环境变量没有设置好。

并且,在KDevelop中也需要设置一下,以使得它能够找到Qt 4的位置。
欢迎访问我的博客,一起学习提高
http://blog.csdn.net/qter_wd007
快速回复
限100 字节
 
上一个 下一个