织梦CMS - 轻松建站从此开始!

罗索

Qt/QTE 编译安装问题与解决方法(2)

落鹤生 发布于 2011-01-10 09:07 点击:次 
let's continue the unfinished work.
TAG:

first,

try to run the dome in Qt/Embedded directory.

  1. [john@localhost ~]$ cd /root/
  2. bash: cd: /root/: 权限不够
  3. [john@localhost ~]$ su
  4. 密码:
  5. [root@localhost john]# cd /root/
  6. [root@localhost ~]# ls
  7. 2410clQt  anaconda-ks.cfg  install.log  install.log.syslog
  8. [root@localhost ~]# cd 2410clQt/
  9. [root@localhost 2410clQt]# export QTEDIR=$PWD/qt-2.3.10
    [root@localhost 2410clQt]# $QTEDIR/bin/qvfb -width 640 -height 480
    /root/2410clQt/qt-2.3.10/bin/qvfb: error while loading shared libraries: libqt.so
  10. [root@localhost 2410clQt]# export PATH=$QTEDIR/bin:$PATH
    [root@localhost 2410clQt]# $QTEDIR/bin/qvfb -width 640 -height 480
    /root/2410clQt/qt-2.3.10/bin/qvfb: error while loading shared libraries: libqt.so.2: cannot open shared object file: No such file or directory
    [root@localhost 2410clQt]#  export LD_LIBRARY_PATH=$QTEDIR/lib:$QT2DIR/lib:$LD_LIBRARY_PATH
    [root@localhost 2410clQt]# $QTEDIR/bin/qvfb -width 640 -height 480
    /root/2410clQt/qt-2.3.10/bin/qvfb: error while loading shared libraries: libqt.so.2: cannot open shared object file: No such file or directory
问题五:在编译Qt/Embedded的过程中,第四步查看运行结果:输入qvfb -width 640 -height -480 &后,出现qvfb: error while loading shared libraries: libqt.so.2: cannot open shared object file: No such file or directory

错误原因:没有找到libqt.so.2的路径,而libqt.so.2存在QT2DIR目录下,这说明路径又设置错误。

解决方法:LD_LIBRARY_PATH路径错误,输入echo $QT2DIR

echo $QTEDIR  echo $LD_LIBRARY_PATH,确定每一个返回路径都是存在而且是有效的。

http://www.linuxdiyf.com/bbs/thread-103277-1-1.html

  1. [root@localhost 2410clQt]# echo $QT2DIR
  2.  
  3. [root@localhost 2410clQt]# export QT2DIR=/root/2410clQt/qt-2.3.2
  4. [root@localhost 2410clQt]# $QTEDIR/bin/qvfb -width 640 -height 480
  5. /root/2410clQt/qt-2.3.10/bin/qvfb: error while loading shared libraries: libqt.so.2: cannot open shared object file: No such file or directory
  6. [root@localhost 2410clQt]# export QT2DIR=/root/2410clQt/qt-2.3.2/
  7. [root@localhost 2410clQt]# $QTEDIR/bin/qvfb -width 640 -height 480
  8. /root/2410clQt/qt-2.3.10/bin/qvfb: error while loading shared libraries: libqt.so.2: cannot open shared object file: No such file or directory
  9. [root@localhost 2410clQt]#

error still exist.

  1. [root@localhost 2410clQt]# export QTEDIR=$PWD/qt-2.3.10
  2. [root@localhost 2410clQt]# export QTDIR=$QT2DIR
  3. [root@localhost 2410clQt]# export PATH=$QTDIR/bin:$PATH
  4. [root@localhost 2410clQt]# export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
  5. [root@localhost 2410clQt]# $QTEDIR/bin/qvfb -width 640 -height 480
  6.  

pass ,

the virtual framebuffer  work correctly.

so the reason may exist here.

let's close all shell window, re-do all above , to make sure we have find the true reason.

  1. [john@localhost ~]$ su
  2. 密码:
  3. [root@localhost john]# cd ~/2410clQt
  4. [root@localhost 2410clQt]# export QTEDIR=$PWD/qt-2.3.10
  5. [root@localhost 2410clQt]#  export QTDIR=$QTEDIR
  6. [root@localhost 2410clQt]#  export PATH=$QTEDIR/bin:$PATH
  7. [root@localhost 2410clQt]#  $QTEDIR/bin/qvfb -width 640 -height 480
  8. /root/2410clQt/qt-2.3.10/bin/qvfb: error while loading shared libraries: libqt.so.2: cannot open shared object file: No such file or directory
  9. [root@localhost 2410clQt]#  export QT2DIR=/root/2410clQt/qt-2.3.2
  10. [root@localhost 2410clQt]#  export QTDIR=$QT2DIR
  11. [root@localhost 2410clQt]# export PATH=$QTDIR/bin:$PATH
  12. [root@localhost 2410clQt]#  $QTEDIR/bin/qvfb -width 640 -height 480
  13. /root/2410clQt/qt-2.3.10/bin/qvfb: error while loading shared libraries: libqt.so.2: cannot open shared object file: No such file or directory
  14. [root@localhost 2410clQt]# export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
  15. [root@localhost 2410clQt]# $QTEDIR/bin/qvfb -width 640 -height 480
  16. Using display 0
  17. [root@localhost 2410clQt]# 
  18.  

pass .

now , i am sure , we'd solve the problem by giving the right directory of libqt.so.2, which is exist at /root/2410clqt/qt-2.3.2, at LD_LIBRARY_PATH, not PATH.

  1. [root@localhost 2410clQt]#  export QTEDIR=$PWD/qt-2.3.10
  2. [root@localhost 2410clQt]# cd $QTEDIR
  3. [root@localhost qt-2.3.10]# cd examples/
  4. [root@localhost examples]# ./launcher/
  5. bash: ./launcher/: is a directory
  6. [root@localhost examples]# cd launcher/
  7. [root@localhost launcher]# ./launcher 
  8. Cannot find font definition file /lib/fonts/fontdir - is $QTDIR set correctly?
  9. [root@localhost launcher]#  export QT2DIR=/root/2410clQt/qt-2.3.2
  10. [root@localhost launcher]#  export QTDIR=$QT2DIR
  11. [root@localhost launcher]# ./launcher 
  12. Cannot find font definition file /root/2410clQt/qt-2.3.2/lib/fonts/fontdir - is $QTDIR set correctly?
  13. [root@localhost launcher]# cd ~/2410clQt
  14. [root@localhost 2410clQt]# cd ~/2410clQt
  15. [root@localhost 2410clQt]#  export QTEDIR=$PWD/qt-2.3.10
  16. [root@localhost 2410clQt]# export QTDIR=$QTEDIR
  17. [root@localhost 2410clQt]# cd $QTEDIR/examples/launcher
  18. [root@localhost launcher]# ./launcher 
  19. libpng error: Valid palette required for paletted images

the example program now run successfully

now , let's begin the page of 144 's task.

  1. [root@localhost launcher]# cd /root/2410clQt/
  2. [root@localhost 2410clQt]# ls
  3. qt-2.3.10  qt-embedded-2.3.10-free.tar.gz  tmake-1.13
  4. qt-2.3.2   qt-x11-2.3.2.tar.gz             tmake-1.13.tar.gz
  5. [root@localhost 2410clQt]# mkdir exp
  6. [root@localhost 2410clQt]# cd exp
  7. [root@localhost exp]# vi hello.cpp
  8. [root@localhost exp]# cat -n hello.cpp 
  9.      1  //hello.cpp
  10.      2  #include <qapplication.h>
  11.      3  #include <qlabel.h>
  12.      4  int main(int argc,char **argv)
  13.      5  {
  14.      6      QApplication app(argc,argv);
  15.      7      QLabel *hello=new QLabel("Hello world!",0);
  16.      8      app.setMainWidget(hello);
  17.      9      hello->show();
  18.     10      return app.exec();
  19.     11  }
  20. [root@localhost exp]# export TMAKEDIR=/root/2410clQt/tmake-1.13
  21. [root@localhost exp]# $TMAKEDIR/bin/progen --help
  22. Usage:
  23.     progen [options] [files]
  24. Options:
  25.     -lower   Lower-case letters filenames (useful for non-Unix)
  26.     -n name  Specify a project name (= TARGET)
  27.     -o file  Write output to "file"
  28.     -t file  Specify a template file other than qtapp
  29.     -d directory Search for files in specified directory and subdirectories[root@localhost exp]# $TMAKEDIR/bin/progen -t app.t -o hello.pro
  30. [root@localhost exp]# cat -n hello.pro
  31.      1  TEMPLATE    = app
  32.      2  CONFIG      = qt warn_on release
  33.      3  HEADERS     = 
  34.      4  SOURCES     = hello.cpp
  35.      5  INTERFACES  = 
  36. [root@localhost exp]# echo $TMAKEPATH
  37.  
  38. [root@localhost exp]# export TMAKEPATH=$TMAKEDIR/lib/linux-g++
  39. [root@localhost exp]# 
  40.  
  1. [root@localhost exp]# echo $TMAKEPATH
  2.  
  3. [root@localhost exp]# export TMAKEPATH=$TMAKEDIR/lib/linux-g++
  4. [root@localhost exp]# echo $TMAKEPATH
  5. /root/2410clQt/tmake-1.13/lib/linux-g++
  6. [root@localhost exp]# export QTEDIR=/root/2410clQt/qt-2.3.10
  7. [root@localhost exp]# $TMAKEDIR/bin/tmake -o Makefile hello.pro
  8. [root@localhost exp]# ls
  9. hello.cpp  hello.pro  Makefile
  10. [root@localhost exp]# make
  11. g++ -c -pipe -Wall -W -O2 -DNO_DEBUG -I/root/2410clQt/qt-2.3.10/include -o hello.o hello.cpp
  12. g++  -o hello hello.o   -L/root/2410clQt/qt-2.3.10/lib -L/usr/X11R6/lib -lqt -lXext -lX11 -lm
  13. /usr/bin/ld: cannot find -lqt
  14. collect2: ld 返回 1
  15. make: *** [hello] 错误 1
  16. [root@localhost exp]# 
  17.  

在环境变量LD_LIBRARY_PATH所指向的路径中,找不到libqt.so动态链接库

  1. [root@localhost exp]# ls
  2. hello.cpp  hello.pro  Makefile
  3. [root@localhost exp]# make
  4. g++ -c -pipe -Wall -W -O2 -DNO_DEBUG -I/root/2410clQt/qt-2.3.10/include -o hello.o hello.cpp
  5. g++  -o hello hello.o   -L/root/2410clQt/qt-2.3.10/lib -L/usr/X11R6/lib -lqt -lXext -lX11 -lm
  6. /usr/bin/ld: cannot find -lqt
  7. collect2: ld 返回 1
  8. make: *** [hello] 错误 1
  9. [root@localhost exp]# export QTDIR=/root/2410clQt/qt-2.3.2
  10. [root@localhost exp]# export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
  11. [root@localhost exp]# make
  12. g++  -o hello hello.o   -L/root/2410clQt/qt-2.3.2/lib -L/usr/X11R6/lib -lqt -lXext -lX11 -lm
  13. [root@localhost exp]# ls
  14. hello  hello.cpp  hello.o  hello.pro  Makefile
  15. [root@localhost exp]# 

run ./hello

successfully

but , we will find that , it's a PC program, even we have started the virtual framebuffer , this program is still run under x11 , not  into the Virtual frame-buffer.

why?

reason:  TMAKEPATH   AND   QTDIR   's setting is not correct.

  1. [root@localhost exp]# cd $TMAKEPATH
  2. [root@localhost linux-g++]# LS
  3. bash: LS: command not found
  4. [root@localhost linux-g++]# ls
  5. app.t  lib.t  subdirs.t  tmake.conf
  6. [root@localhost linux-g++]# cd /root/2410clQt/exp/
  7. [root@localhost exp]# ls
  8. hello  hello.cpp  hello.o  hello.pro  Makefile
  9. [root@localhost exp]# echo $TMAKEPATH
  10. /root/2410clQt/tmake-1.13/lib/linux-g++
  11. [root@localhost exp]# echo $TMAKEdir
  12.  
  13. [root@localhost exp]# echo $TMAKEDIR
  14. /root/2410clQt/tmake-1.13
  15. [root@localhost exp]# export TMAKEPATH=/root/2410clQt/tmake-1.13/lib/qws/linux-x86-g++/
  16. [root@localhost exp]# make
  17. make: Nothing to be done for `all'.
  18. [root@localhost exp]# echo $QTDIR
  19. /root/2410clQt/qt-2.3.2
  20. [root@localhost exp]# export $QTDIR=/root/2410clQt/qt-2.3.10
  21. bash: export: `/root/2410clQt/qt-2.3.2=/root/2410clQt/qt-2.3.10': not a valid identifier
  22. [root@localhost exp]# export QTDIR=/root/2410clQt/qt-2.3.10
  23. [root@localhost exp]# $TMAKEDIR/bin/tmake -o Makefile hello.pro
  24. [root@localhost exp]# make
  25. make: Nothing to be done for `all'.
  26. [root@localhost exp]# rm hello
  27. rm:是否删除 普通文件 “hello”? y
  28. [root@localhost exp]# make
  29. g++  -o hello hello.o   -L/root/2410clQt/qt-2.3.10/lib -lm -lqte
  30. [root@localhost exp]# ./hello
  31. QSocket::writeBlock: Socket is not open
  32. QSocket::writeBlock: Socket is not open
  33. QSocket::writeBlock: Socket is not open
  34. QSocket::writeBlock: Socket is not open
  35. No Qt/Embedded server appears to be running.
  36. If you want to run hello as a server,
  37. add the "-qws" command-line option.
#here , we also run the virtual frame buffer environment
  1. [root@localhost exp]# ./hello
  2. QSocket::writeBlock: Socket is not open
  3. QSocket::writeBlock: Socket is not open
  4. QSocket::writeBlock: Socket is not open
  5. QSocket::writeBlock: Socket is not open
  6. No Qt/Embedded server appears to be running.
  7. If you want to run hello as a server,
  8. add the "-qws" command-line option.
  9. [root@localhost exp]# ./hello -qws
  10. 段错误
  11. [root@localhost exp]# ./hello -qws
  12. 段错误
  13. [root@localhost exp]# 
  14.  
  15.  

           ;-(     :-) 

if we don't run the VFB environment, there is also an error.

  1. [root@localhost exp]# ./hello -qws
  2. Can't open framebuffer device /dev/fb0
  3. Can't open framebuffer device /dev/fb0
  4.  driver cannot connect
  5. [root@localhost exp]#

God help me ,please.

here is the shell code we used to run the VFB environment

  1. [john@localhost ~]$ su
  2. 密码:
  3. [root@localhost john]# cd ~/2410clQt
  4. [root@localhost 2410clQt]# export QT2DIR=/root/2410clQt/qt-2.3.2
  5.  export QTDIR=$QT2DIR
  6.  export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
  7. export QTEDIR=$PWD/qt-2.3.10
  8. $QTEDIR/bin/qvfb -width 640 -height 480
  9. Using display 0

all shell commands are as follows.

  1. [john@localhost ~]$ su
  2. 密码:
  3. [root@localhost john]# cd ~/2410clQt
  4. [root@localhost 2410clQt]# # export QT2DIR=/root/2410clQt/qt-2.3.2
  5. [root@localhost 2410clQt]# #  export QTDIR=$QT2DIR
  6. [root@localhost 2410clQt]# #  export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
  7. [root@localhost 2410clQt]# # export QTEDIR=$PWD/qt-2.3.10
  8. [root@localhost 2410clQt]# # $QTEDIR/bin/qvfb -width 640 -height 480
  9. [root@localhost 2410clQt]# # export QT2DIR=/root/2410clQt/qt-2.3.2
  10. [root@localhost 2410clQt]# #  export QTDIR=$QT2DIR
  11. [root@localhost 2410clQt]# #  export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
  12. [root@localhost 2410clQt]# # export QTEDIR=$PWD/qt-2.3.10
  13. [root@localhost 2410clQt]#  export QT2DIR=/root/2410clQt/qt-2.3.2
  14. [root@localhost 2410clQt]#   export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH[root@localhost 2410clQt]#  export QTEDIR=$PWD/qt-2.3.10
  15. [root@localhost 2410clQt]#  $QTEDIR/bin/qvfb -width 640 -height 480
  16. /root/2410clQt/qt-2.3.10/bin/qvfb: error while loading shared libraries: libqt.so.2: cannot open shared object file: No such file or directory
  17. [root@localhost 2410clQt]# export QTDIR=$QT2DIR
  18. [root@localhost 2410clQt]#  $QTEDIR/bin/qvfb -width 640 -height 480
  19. /root/2410clQt/qt-2.3.10/bin/qvfb: error while loading shared libraries: libqt.so.2: cannot open shared object file: No such file or directory
  20. [root@localhost 2410clQt]# export QT2DIR=/root/2410clQt/qt-2.3.2
  21. [root@localhost 2410clQt]# export QTDIR=$QT2DIR
  22. [root@localhost 2410clQt]# export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
  23. [root@localhost 2410clQt]# export QTEDIR=$PWD/qt-2.3.10
  24. [root@localhost 2410clQt]# $QTEDIR/bin/qvfb -width 640 -height 480
  25. Using display 0
  26. [root@localhost 2410clQt]# $QTEDIR/bin/qvfb -width 640 -height 480 &
  27. [1] 2975
  28. [root@localhost 2410clQt]# Using display 0
  29. cd exp
  30. [root@localhost exp]# ls
  31. hello  hello.cpp  hello.pro  Makefile
  32. [root@localhost exp]# ./hello -qws
  33. ./hello: error while loading shared libraries: libqte.so.2: cannot open shared object file: No such file or directory
  34. [root@localhost exp]# export QTDIR=/root/2410clQt/qt-2.3.10
  35. [root@localhost exp]# ./hello -qws
  36. ./hello: error while loading shared libraries: libqte.so.2: cannot open shared object file: No such file or directory
  37. [root@localhost exp]#  export QTEDIR=/root/2410clQt/qt-2.3.10
  38. [root@localhost exp]# ./hello -qws
  39. ./hello: error while loading shared libraries: libqte.so.2: cannot open shared object file: No such file or directory
  40. [root@localhost exp]# export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
  41. [root@localhost exp]# ./hello -qws
  42. 段错误
  43. [root@localhost exp]# make
  44. g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -fno-default-inline -DNO_DEBUG -I/root/2410clQt/qt-2.3.10/include -o hello.o hello.cpp
  45. g++  -o hello hello.o   -L/root/2410clQt/qt-2.3.10/lib -lm -lqte
  46. [root@localhost exp]# ls
  47. hello  hello.cpp  hello.o  hello.pro  Makefile
  48. [root@localhost exp]# ./hello -qws

the program run at line 41 is still yesterday's.

but the hello.cpp which compiled at line 43, has been changed. I replace it with the code copy from the direction book, it list at page 144 at this book.

 

(bloghome)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201101/10732.html]
本文出处:CSDN博客 作者:bloghome
顶一下
(2)
100%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容