百问网Linux技术区Linux应用开发 qt程序一直编译不通过

1  /  1  页   1 跳转 查看:2206

qt程序一直编译不通过

qt程序一直编译不通过

我现在可以按照您的那本书,运行Helloworld程序,但是我按照QT手册编译QT自带的例程时,总是显示
/qtopia-free-2.2.0_x86/qt2/lib  -o ./t2 main.o  -lqte 
/usr/bin/ld: cannot find -lqte
collect2: ld returned 1 exit status
make: *** [t2] Error 1

不知道是怎么回事,已经困扰我好几天了。
 

回复:qt程序一直编译不通过

环境变量有没有设置好?
你搜索一下,看看有没有qte库:
find -name "libqte*" -R
 

回复: qt程序一直编译不通过

按照您的方法,我找了一下
blue@blue-desktop:/work/GUI$ find -name "libqte*"
./qtopia/qtopia-free-2.2.0_x86/qtopia/image/opt/Qtopia/lib/libqte.so.2
./qtopia/qtopia-free-2.2.0_x86/qtopia/image/opt/Qtopia/lib/libqte.so.2.3
./qtopia/qtopia-free-2.2.0_x86/qtopia/image/opt/Qtopia/lib/libqte.so
./qtopia/qtopia-free-2.2.0_x86/qtopia/image/opt/Qtopia/lib/libqte.so.2.3.12
./qtopia/qtopia-free-2.2.0_x86/qtopia/lib/libqte.so.2
./qtopia/qtopia-free-2.2.0_x86/qtopia/lib/libqte.so.2.3
./qtopia/qtopia-free-2.2.0_x86/qtopia/lib/libqte.so
./qtopia/qtopia-free-2.2.0_x86/qtopia/lib/libqte.so.2.3.12
blue@blue-desktop:/work/GUI/qtopia/qtopia-free-2.2.0_x86/qt2/lib$ ls -l
total 7024
drwx------ 2 blue users  28672 2005-11-11 10:38 fonts
lrwxrwxrwx 1 blue root      15 2008-09-20 17:16 libqt.so -> libqt.so.2.3.12
lrwxrwxrwx 1 blue root      15 2008-09-20 17:16 libqt.so.2 -> libqt.so.2.3.12
lrwxrwxrwx 1 blue root      15 2008-09-20 17:16 libqt.so.2.3 -> libqt.so.2.3.12
-rwxr-xr-x 1 blue root  7105997 2008-09-20 17:16 libqt.so.2.3.12
lrwxrwxrwx 1 blue root      17 2008-09-20 17:17 libqutil.so -> libqutil.so.1.0.0
lrwxrwxrwx 1 blue root      17 2008-09-20 17:17 libqutil.so.1 -> libqutil.so.1.0.0
lrwxrwxrwx 1 blue root      17 2008-09-20 17:17 libqutil.so.1.0 -> libqutil.so.1.0.0
-rwxr-xr-x 1 blue root    42357 2008-09-20 17:17 libqutil.so.1.0.0
您看是缺少文件还是其它问题呢?
谢谢您
 

回复:qt程序一直编译不通过

应该是环境变量的设置问题,
把完整的编译记录贴出来
 

回复:qt程序一直编译不通过

blue@blue-desktop:/work/qtTest/tutorial/t1$ make
gcc  -o t1 main.o  -L/work/GUI/qtopia/qtopia-free-2.2.0_x86/qt2/lib -lqte
/usr/bin/ld: cannot find -lqte
collect2: ld returned 1 exit status
make: *** [t1] Error 1

我编译的是QT2里tutrol第一个例子,只有一个main.cpp
 

回复:qt程序一直编译不通过

直接运行这个看看:
gcc  -o t1 main.o  -L/work/GUI/qtopia/qtopia-free-2.2.0_x86/qt2/ -lqte
或者:
gcc  -o t1 main.o  /work/GUI/qtopia/qtopia-free-2.2.0_x86/qt2/lib/libqte.so.2.3.12

是libqte.so.2.3.12,还是其他,你自己看看:不是链接文件
 

回复:qt程序一直编译不通过

按您的方法我执行了一下,把/lib下不是链接文件 的我也都试了,出了以下的错误:
main.o: In function `main':
main.cpp.text+0x3a): undefined reference to `QApplication:Application(int&, char**)'
main.cpp.text+0x4a): undefined reference to `QString:String(char const*)'
main.cpp.text+0x66): undefined reference to `QPushButton:PushButton(QString const&, QWidget*, char const*)'
main.cpp.text+0x7a): undefined reference to `QString::shared_null'
main.cpp.text+0x84): undefined reference to `QStringData:eleteSelf()'
main.cpp:(.text+0x9c): undefined reference to `QPushButton::resize(int, int)'
main.cpp:(.text+0xa8): undefined reference to `QApplication::setMainWidget(QWidget*)'
main.cpp:(.text+0xb0): undefined reference to `QWidget::show()'
main.cpp:(.text+0xb8): undefined reference to `QApplication::exec()'
main.cpp:(.text+0xc2): undefined reference to `QPushButton:QPushButton()'
main.cpp:(.text+0xca): undefined reference to `QApplication:QApplication()'
main.cpp:(.text+0xe5): undefined reference to `QString::shared_null'
collect2: ld returned 1 exit status
 

回复: qt程序一直编译不通过



引用:
原帖由 blue 于 2008-9-27 10:39:00 发表
按您的方法我执行了一下,把/lib下不是链接文件 的我也都试了,出了以下的错误:
main.o: In function `main':
main.cpp.text+0x3a): undefined reference to `QApplication:main.cpp.text+0x4a): undefined re


这个是典型的库文件没有找到。lz找找路径上的问题看。
 

回复: qt程序一直编译不通过

这个问题我以前遇到过,但是是找不到-lm-lqte,和你那个有一点不相同,当时修改了相应文件夹下的Makefile就编译通过了。
 

回复:qt程序一直编译不通过

请问楼上的朋友,你是指把Makefile里的-lqte 改成-lqt -mt 吗?
 

回复:qt程序一直编译不通过

我搞定了,但不知道怎么用..
 

回复:qt程序一直编译不通过

怎么搞定的 ,分享下经验啊
 

回复:qt程序一直编译不通过

我也是遇到这样的问题了,分享一下成功经验啊
 

回复:qt程序一直编译不通过

vi Makefile

在LIBS=    这行的后面添加 -lm -lstdc++

保存退出

Recompile to see if it works
 
1  /  1  页   1 跳转

地址:广东省深圳市南山区南山大道3003号久商大厦C-1406;邮编:518052;电话:0755-86200561

粤ICP备09041549号, 版权所有 百问网   Sitemap

Powered by Discuz!NT 2.0.1214    Copyright © 2001-2010 Comsenz Inc.
Processed in 0.078125 second(s) , 3 queries.
返顶部