let's continue the unfinished work.
first,
try to run the dome in Qt/Embedded directory.
- [john@localhost ~]$ cd /root/
- bash: cd: /root/: 权限不够
- [john@localhost ~]$ su
- 密码:
- [root@localhost john]# cd /root/
- [root@localhost ~]# ls
- 2410clQt anaconda-ks.cfg install.log install.log.syslog
- [root@localhost ~]# cd 2410clQt/
- [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 - [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
错误原因:没有找到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
- [root@localhost 2410clQt]# echo $QT2DIR
- [root@localhost 2410clQt]# export QT2DIR=/root/2410clQt/qt-2.3.2
- [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 QT2DIR=/root/2410clQt/qt-2.3.2/
- [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]#
error still exist.
- [root@localhost 2410clQt]# export QTEDIR=$PWD/qt-2.3.10
- [root@localhost 2410clQt]# export QTDIR=$QT2DIR
- [root@localhost 2410clQt]# export PATH=$QTDIR/bin:$PATH
- [root@localhost 2410clQt]# export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
- [root@localhost 2410clQt]# $QTEDIR/bin/qvfb -width 640 -height 480
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.
- [john@localhost ~]$ su
- 密码:
- [root@localhost john]# cd ~/2410clQt
- [root@localhost 2410clQt]# export QTEDIR=$PWD/qt-2.3.10
- [root@localhost 2410clQt]# export QTDIR=$QTEDIR
- [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 QT2DIR=/root/2410clQt/qt-2.3.2
- [root@localhost 2410clQt]# export QTDIR=$QT2DIR
- [root@localhost 2410clQt]# export PATH=$QTDIR/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=$QTDIR/lib:$LD_LIBRARY_PATH
- [root@localhost 2410clQt]# $QTEDIR/bin/qvfb -width 640 -height 480
- Using display 0
- [root@localhost 2410clQt]#
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.
- [root@localhost 2410clQt]# export QTEDIR=$PWD/qt-2.3.10
- [root@localhost 2410clQt]# cd $QTEDIR
- [root@localhost qt-2.3.10]# cd examples/
- [root@localhost examples]# ./launcher/
- bash: ./launcher/: is a directory
- [root@localhost examples]# cd launcher/
- [root@localhost launcher]# ./launcher
- Cannot find font definition file /lib/fonts/fontdir - is $QTDIR set correctly?
- [root@localhost launcher]# export QT2DIR=/root/2410clQt/qt-2.3.2
- [root@localhost launcher]# export QTDIR=$QT2DIR
- [root@localhost launcher]# ./launcher
- Cannot find font definition file /root/2410clQt/qt-2.3.2/lib/fonts/fontdir - is $QTDIR set correctly?
- [root@localhost launcher]# cd ~/2410clQt
- [root@localhost 2410clQt]# cd ~/2410clQt
- [root@localhost 2410clQt]# export QTEDIR=$PWD/qt-2.3.10
- [root@localhost 2410clQt]# export QTDIR=$QTEDIR
- [root@localhost 2410clQt]# cd $QTEDIR/examples/launcher
- [root@localhost launcher]# ./launcher
- libpng error: Valid palette required for paletted images
the example program now run successfully.
now , let's begin the page of 144 's task.
- [root@localhost launcher]# cd /root/2410clQt/
- [root@localhost 2410clQt]# ls
- qt-2.3.10 qt-embedded-2.3.10-free.tar.gz tmake-1.13
- qt-2.3.2 qt-x11-2.3.2.tar.gz tmake-1.13.tar.gz
- [root@localhost 2410clQt]# mkdir exp
- [root@localhost 2410clQt]# cd exp
- [root@localhost exp]# vi hello.cpp
- [root@localhost exp]# cat -n hello.cpp
- 1 //hello.cpp
- 2 #include <qapplication.h>
- 3 #include <qlabel.h>
- 4 int main(int argc,char **argv)
- 5 {
- 6 QApplication app(argc,argv);
- 7 QLabel *hello=new QLabel("Hello world!",0);
- 8 app.setMainWidget(hello);
- 9 hello->show();
- 10 return app.exec();
- 11 }
- [root@localhost exp]# export TMAKEDIR=/root/2410clQt/tmake-1.13
- [root@localhost exp]# $TMAKEDIR/bin/progen --help
- Usage:
- progen [options] [files]
- Options:
- -lower Lower-case letters filenames (useful for non-Unix)
- -n name Specify a project name (= TARGET)
- -o file Write output to "file"
- -t file Specify a template file other than qtapp
- -d directory Search for files in specified directory and subdirectories[root@localhost exp]# $TMAKEDIR/bin/progen -t app.t -o hello.pro
- [root@localhost exp]# cat -n hello.pro
- 1 TEMPLATE = app
- 2 CONFIG = qt warn_on release
- 3 HEADERS =
- 4 SOURCES = hello.cpp
- 5 INTERFACES =
- [root@localhost exp]# echo $TMAKEPATH
- [root@localhost exp]# export TMAKEPATH=$TMAKEDIR/lib/linux-g++
- [root@localhost exp]#
- [root@localhost exp]# echo $TMAKEPATH
- [root@localhost exp]# export TMAKEPATH=$TMAKEDIR/lib/linux-g++
- [root@localhost exp]# echo $TMAKEPATH
- /root/2410clQt/tmake-1.13/lib/linux-g++
- [root@localhost exp]# export QTEDIR=/root/2410clQt/qt-2.3.10
- [root@localhost exp]# $TMAKEDIR/bin/tmake -o Makefile hello.pro
- [root@localhost exp]# ls
- hello.cpp hello.pro Makefile
- [root@localhost exp]# make
- g++ -c -pipe -Wall -W -O2 -DNO_DEBUG -I/root/2410clQt/qt-2.3.10/include -o hello.o hello.cpp
- g++ -o hello hello.o -L/root/2410clQt/qt-2.3.10/lib -L/usr/X11R6/lib -lqt -lXext -lX11 -lm
- /usr/bin/ld: cannot find -lqt
- collect2: ld 返回 1
- make: *** [hello] 错误 1
- [root@localhost exp]#
- [root@localhost exp]# ls
- hello.cpp hello.pro Makefile
- [root@localhost exp]# make
- g++ -c -pipe -Wall -W -O2 -DNO_DEBUG -I/root/2410clQt/qt-2.3.10/include -o hello.o hello.cpp
- g++ -o hello hello.o -L/root/2410clQt/qt-2.3.10/lib -L/usr/X11R6/lib -lqt -lXext -lX11 -lm
- /usr/bin/ld: cannot find -lqt
- collect2: ld 返回 1
- make: *** [hello] 错误 1
- [root@localhost exp]# export QTDIR=/root/2410clQt/qt-2.3.2
- [root@localhost exp]# export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
- [root@localhost exp]# make
- g++ -o hello hello.o -L/root/2410clQt/qt-2.3.2/lib -L/usr/X11R6/lib -lqt -lXext -lX11 -lm
- [root@localhost exp]# ls
- hello hello.cpp hello.o hello.pro Makefile
- [root@localhost exp]#
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.
- [root@localhost exp]# cd $TMAKEPATH
- [root@localhost linux-g++]# LS
- bash: LS: command not found
- [root@localhost linux-g++]# ls
- app.t lib.t subdirs.t tmake.conf
- [root@localhost linux-g++]# cd /root/2410clQt/exp/
- [root@localhost exp]# ls
- hello hello.cpp hello.o hello.pro Makefile
- [root@localhost exp]# echo $TMAKEPATH
- /root/2410clQt/tmake-1.13/lib/linux-g++
- [root@localhost exp]# echo $TMAKEdir
- [root@localhost exp]# echo $TMAKEDIR
- /root/2410clQt/tmake-1.13
- [root@localhost exp]# export TMAKEPATH=/root/2410clQt/tmake-1.13/lib/qws/linux-x86-g++/
- [root@localhost exp]# make
- make: Nothing to be done for `all'.
- [root@localhost exp]# echo $QTDIR
- /root/2410clQt/qt-2.3.2
- [root@localhost exp]# export $QTDIR=/root/2410clQt/qt-2.3.10
- bash: export: `/root/2410clQt/qt-2.3.2=/root/2410clQt/qt-2.3.10': not a valid identifier
- [root@localhost exp]# export QTDIR=/root/2410clQt/qt-2.3.10
- [root@localhost exp]# $TMAKEDIR/bin/tmake -o Makefile hello.pro
- [root@localhost exp]# make
- make: Nothing to be done for `all'.
- [root@localhost exp]# rm hello
- rm:是否删除 普通文件 “hello”? y
- [root@localhost exp]# make
- g++ -o hello hello.o -L/root/2410clQt/qt-2.3.10/lib -lm -lqte
- [root@localhost exp]# ./hello
- QSocket::writeBlock: Socket is not open
- QSocket::writeBlock: Socket is not open
- QSocket::writeBlock: Socket is not open
- QSocket::writeBlock: Socket is not open
- No Qt/Embedded server appears to be running.
- If you want to run hello as a server,
- add the "-qws" command-line option.
#here , we also run the virtual frame buffer environment
- [root@localhost exp]# ./hello
- QSocket::writeBlock: Socket is not open
- QSocket::writeBlock: Socket is not open
- QSocket::writeBlock: Socket is not open
- QSocket::writeBlock: Socket is not open
- No Qt/Embedded server appears to be running.
- If you want to run hello as a server,
- add the "-qws" command-line option.
- [root@localhost exp]# ./hello -qws
- 段错误
- [root@localhost exp]# ./hello -qws
- 段错误
- [root@localhost exp]#
;-( :-)
if we don't run the VFB environment, there is also an error.
- [root@localhost exp]# ./hello -qws
- Can't open framebuffer device /dev/fb0
- Can't open framebuffer device /dev/fb0
- driver cannot connect
- [root@localhost exp]#
God help me ,please.
here is the shell code we used to run the VFB environment
- [john@localhost ~]$ su
- 密码:
- [root@localhost john]# cd ~/2410clQt
- [root@localhost 2410clQt]# export QT2DIR=/root/2410clQt/qt-2.3.2
- export QTDIR=$QT2DIR
- export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
- export QTEDIR=$PWD/qt-2.3.10
- $QTEDIR/bin/qvfb -width 640 -height 480
- Using display 0