• 5327阅读
  • 2回复

请教各位高手关于QT编程的问题 [复制链接]

上一主题 下一主题
离线wolf841128
 
只看楼主 倒序阅读 楼主  发表于: 2008-11-10
— 本帖被 XChinux 执行加亮操作(2008-11-12) —
#include <QtGui/QApplication>
#include <QtGui/QWidget>
#include <QtGui/QLabel>
#include <QtCore/QTextCodec>
int main (int argc, char *argv[])
{
      QApplication app(argc, argv);
      QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));
      QWidget* pWidget = new QWidget;
      QLabel label(pWidget);
      label.setText(QObject::tr("同一个世界,同一个梦想!"));
      pWidget->show();
      return app.exec();
}
这是我在opensuse10.2中,用kdevelop3.5写的一个简单的程序,是基于qt4.3.2编写的
可是我编译的时候出现了下列的提示:
d '/home/wolf841128/hello' && gmake -k
cd src/ && gmake -f Makefile
正在编译 main.cpp (g++)
正在连接 ../bin/hello (g++)
main.o: In function `main':
main.cpp:(.text+0x31): undefined reference to `QApplication::QApplication(int&, char**, int)'
main.cpp:(.text+0x95): undefined reference to `QWidget::QWidget(QWidget*, QFlags<Qt::WindowType>)'
main.cpp:(.text+0xb2): undefined reference to `QLabel::QLabel(QWidget*, QFlags<Qt::WindowType>)'
main.cpp:(.text+0xe4): undefined reference to `QLabel::setText(QString const&)'
main.cpp:(.text+0x111): undefined reference to `QApplication::exec()'
main.cpp:(.text+0x11b): undefined reference to `QLabel::~QLabel()'
main.cpp:(.text+0x126): undefined reference to `QApplication::~QApplication()'
main.cpp:(.text+0x141): undefined reference to `QApplication::~QApplication()'
main.cpp:(.text+0x16b): undefined reference to `QLabel::~QLabel()'
collect2: ld returned 1 exit status
gmake[1]: *** [../bin/hello] 错误 1
gmake[1]: 由于错误目标“first”并未重新创建。
gmake: *** [sub-src-make_default] 错误 2
gmake: 由于错误目标“first”并未重新创建。
*** 退出状态:2 ***
请各位高手指点一下,是什么地方出现了问题啊
我的qt4安装在/usr/local/Trolltech/Qt-4.3.2中,我整好长时间了,请各位帮帮忙吧,在这里谢谢了
离线wolf841128
只看该作者 1楼 发表于: 2008-11-10
我感觉有可能是环境变量没有设置好,可是我又不知道在哪设置,请各位帮帮忙吧,谢谢!!!
离线xdman

只看该作者 2楼 发表于: 2008-11-12
的确是环境变量的设置问题,在 .bash_profile 中添加

export  QTDIR=/usr/local/Trolltech/Qt-4.3.4
export  PATH=$QTDIR/biN:$PATH
export  LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH

就可以了
快速回复
限100 字节
 
上一个 下一个