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


let's continue the unfinished work.

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. [root@localhost 2410clQt]# export QT2DIR=/root/2410clQt/qt-2.3.2
  3. [root@localhost 2410clQt]# $QTEDIR/bin/qvfb -width 640 -height 480
  4. /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
  5. [root@localhost 2410clQt]# export QT2DIR=/root/2410clQt/qt-2.3.2/
  6. [root@localhost 2410clQt]# $QTEDIR/bin/qvfb -width 640 -height 480
  7. /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
  8. [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
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]# 
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. [root@localhost exp]# export TMAKEPATH=$TMAKEDIR/lib/linux-g++
  38. [root@localhost exp]# 
  1. [root@localhost exp]# echo $TMAKEPATH
  2. [root@localhost exp]# export TMAKEPATH=$TMAKEDIR/lib/linux-g++
  3. [root@localhost exp]# echo $TMAKEPATH
  4. /root/2410clQt/tmake-1.13/lib/linux-g++
  5. [root@localhost exp]# export QTEDIR=/root/2410clQt/qt-2.3.10
  6. [root@localhost exp]# $TMAKEDIR/bin/tmake -o Makefile hello.pro
  7. [root@localhost exp]# ls
  8. hello.cpp  hello.pro  Makefile
  9. [root@localhost exp]# make
  10. g++ -c -pipe -Wall -W -O2 -DNO_DEBUG -I/root/2410clQt/qt-2.3.10/include -o hello.o hello.cpp
  11. g++  -o hello hello.o   -L/root/2410clQt/qt-2.3.10/lib -L/usr/X11R6/lib -lqt -lXext -lX11 -lm
  12. /usr/bin/ld: cannot find -lqt
  13. collect2: ld 返回 1
  14. make: *** [hello] 错误 1
  15. [root@localhost exp]# 
在环境变量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. [root@localhost exp]# echo $TMAKEDIR
  13. /root/2410clQt/tmake-1.13
  14. [root@localhost exp]# export TMAKEPATH=/root/2410clQt/tmake-1.13/lib/qws/linux-x86-g++/
  15. [root@localhost exp]# make
  16. make: Nothing to be done for `all'.
  17. [root@localhost exp]# echo $QTDIR
  18. /root/2410clQt/qt-2.3.2
  19. [root@localhost exp]# export $QTDIR=/root/2410clQt/qt-2.3.10
  20. bash: export: `/root/2410clQt/qt-2.3.2=/root/2410clQt/qt-2.3.10': not a valid identifier
  21. [root@localhost exp]# export QTDIR=/root/2410clQt/qt-2.3.10
  22. [root@localhost exp]# $TMAKEDIR/bin/tmake -o Makefile hello.pro
  23. [root@localhost exp]# make
  24. make: Nothing to be done for `all'.
  25. [root@localhost exp]# rm hello
  26. rm:是否删除 普通文件 “hello”? y
  27. [root@localhost exp]# make
  28. g++  -o hello hello.o   -L/root/2410clQt/qt-2.3.10/lib -lm -lqte
  29. [root@localhost exp]# ./hello
  30. QSocket::writeBlock: Socket is not open
  31. QSocket::writeBlock: Socket is not open
  32. QSocket::writeBlock: Socket is not open
  33. QSocket::writeBlock: Socket is not open
  34. No Qt/Embedded server appears to be running.
  35. If you want to run hello as a server,
  36. 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]# 

           ;-(     :-) 

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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值