LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1378|回复: 17

qt下怎么编译啊!

[复制链接]
发表于 2003-10-31 09:58:49 | 显示全部楼层 |阅读模式
我手上有KDE 2/QT这本书,但是书上的例子怎么编译啊??在qt界面下,找了半天也没有找到,急盼,谢谢!!!!!!!!!!!1
发表于 2003-10-31 23:12:25 | 显示全部楼层
you can create a new project
then input the source
then compile

notice the first step
 楼主| 发表于 2003-11-2 08:18:53 | 显示全部楼层
I am sorry!
无双斑主,关于qt的资料太少了,我最近在看qt的帮助,但是进展比较缓慢,但是你说的creat a new project,but I can't find where input the source,and no button to compile,so…………
I use the google to find the answer,but the result is ……
发表于 2003-11-2 10:08:17 | 显示全部楼层
用QTDesigner的话,就先创建一个project,再在 .ui.h文件中添加适当的代码
然后再用命令qmake -o makefile ???.pro
            make
没错的话,应该就可以生成可执行文件.
 楼主| 发表于 2003-11-2 16:00:07 | 显示全部楼层
谢谢,qmake后,没有问题,但是make时出现

  1. g++  -o helloworld    -L/usr/lib/qt-3.1/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm
  2. /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crt1.o(.text+0x18): In function `_start':
  3. ../sysdeps/i386/elf/start.S:77: undefined reference to `main'
  4. collect2: ld returned 1 exit status
  5. make: *** [helloworld] Error 1

复制代码

看不懂错误的地方哦!所以……
发表于 2003-11-2 23:36:55 | 显示全部楼层
main函数定义了没有
 楼主| 发表于 2003-11-3 08:34:28 | 显示全部楼层

  1. /****************************************************************************
  2. ** ui.h extension file, included from the uic-generated form implementation.
  3. **
  4. ** If you wish to add, delete or rename functions or slots use
  5. ** Qt Designer which will update this file, preserving your code. Create an
  6. ** init() function in place of a constructor, and a destroy() function in
  7. ** place of a destructor.
  8. *****************************************************************************/
  9. /* helloworld.cpp */
  10. #include <qapplication.h>
  11. #include <qlabel.h>
  12. #include <qstring.h>

  13. int main( int argc, char **argv)
  14. {
  15.     QApplication app(argc,argv);
  16.     QLable *label = new QLabel(NULL);
  17.     QString string ("Hello, world");
  18.     label->setText(string);
  19.     label->setAlignment( Qt:AlignVCenter | Qt::AlignHCenter);
  20.     label->setGeometry(0,0,180,75);
  21.     label->show();
  22.     app.setMainWidget(label);
  23.     return (app.exec());
  24. }
复制代码

书上的例子,应该不会错吧!!!
发表于 2003-11-3 19:52:37 | 显示全部楼层
看看你的.pro文件中有没有这句
SOURCES        += main.cpp
没有的话,加上,再make一把.
 楼主| 发表于 2003-11-3 22:55:20 | 显示全部楼层
加了之后,qmake说找不到main.cpp。晕!!!
发表于 2003-11-4 09:12:45 | 显示全部楼层
那就把SOURCES += main.cpp换成SOURCES += helloworld.cpp试试.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表