搜档网
当前位置:搜档网 › linux上移植qt经验分享

linux上移植qt经验分享

Qt是一个跨平台的C++应用程序开发框架,广泛用于开发GUI程序。使用Qt开发的软件,相同的代码可以在任何支持的平台上编译与运行,而不需要修改源代码。会自动依平台的不同,表现平台特有的图形界面风格。
Qt在嵌入式开发中有着广泛的应用,使用Qt只需编写一次应用程序和UI,无须重新编写源代码,便可跨不同的桌面和嵌入式操作系统进行部署,既节省了时间又降低开发成本。

---------------------------------------------------------------------
一 移植步骤
1,确定linux操作系统版本及编译器版本,版本GCC4.3.5
2,安装tslib库用于支持触摸屏,版本tslib-1.0
3,移植qt库用于支持qt主程序,版本Qt4.8.5
4,移植qt主程序到linux中,版本C_1k_1.14
---------------------------------------------------------------------

---------------------------------------------------------------------
二 linux操作系统版本及编译器版本
cat /proc/version

//DTV1000W_9G10平台
Linux version 2.6.30.10 (root@wangwei-virtual-machine) (gcc version 4.2.3 (Sourcery G++ Lite 2008q1-126)) #28 Thu Nov 22 19:55:12 CST 2012
液晶屏:5.6寸(640×480)


//公司ARM9平台
Linux version 2.6.39 (root@ubuntu) (gcc version 4.3.5 (Buildroot 2011.05) ) #74 Tue Jan 8 19:35:16 CST 2013

//虚拟机上的x86平台
Linux version 2.6.32-33-generic (buildd@rothera) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #70-Ubuntu SMP Thu Jul 7 21:09:46 UTC 2011


//新版CCU的
//Linux version 2.6.39 (root@ubuntu) (gcc version 4.2.4) #70 Tue Nov 12 17:01:38 CST 2013
此处显示gcc version 4.2.4 但实际中需要用 gcc version 4.3.5交叉编译才能运行,与系统移植时的命名有关。
液晶屏:10.4寸(800×600)

---------------------------------------------------------------------



----------------------------------------------------------------------
三 安装tslib
装tslib,主要是为了校准触摸屏以及去抖等功能,
在虚拟机上执行下列命令,
cp tslib-1.0.tar.bz2 /home
tar -xvjf tslib-1.0.tar.bz2
cd tslib-1.0
./autogen.sh

问题1 ,在执行 ./autogen.sh 时、出现如下错误
libtoolize: $pkgltdldir not a directory: `/home/ti-sdk-am335x-evm/linux-devkit/share/libtool'
autoreconf: libtoolize failed with exit status: 1
解决3,在系统目录中创建 ti-sdk-am335x-evm 文件夹,将linux-devkit 放到这个文件夹中
mkdir ti-sdk-am335x-evm
cp -rf ./linux-devkit ti-sdk-am335x-evm/



./configure CC=arm-linux-gcc-4.3.5 --build=i686-pc-linux --target=arm-linux --prefix=/opt/tslib-1.3 --host=arm-linux ac_cv_func_malloc_0_nonnull=yes --enable-inputapi=yes

CC=arm-linux-gcc-4.3.5 ./configure --prefix=/opt/tslib-1.3 --host=arm-linux ac_cv_func_malloc_0_nonnull=yes
修改./config.h 将文件中的 #define malloc rpl_malloc 这句话屏蔽
gedit ./config.h
make
make install

问题1,在make时

出现错误
/home/AT9x25/buildroot-2011.05/output/host/usr/lib/gcc/arm-unknown-linux-uclibcgnueabi/4.3.5/../../../../arm-unknown-linux-uclibcgnueabi/bin/ld: unknown architecture of input file `.libs/ts_fd.o' is incompatible with arm output
collect2: ld returned 1 exit status
make[2]: *** [https://www.sodocs.net/doc/e02081784.html,] 错误 1
make[2]:正在离开目录 `/mnt/hgfs/CCU/QT移植相关/tslib-1.0/src'
make[1]: *** [all-recursive] 错误 1
make[1]:正在离开目录 `/mnt/hgfs/CCU/QT移植相关/tslib-1.0'
make: *** [all] 错误 2
解决1,原因是以开始我将 tslib-1.0.tar.bz2 放在挂载盘”/mnt/hgfs/CCU/QT移植相关“ 下面,将该文件挪到/home文件夹下后问题消除,得出一个交叉编译的一个通用惯例,就是make,instal等操作不能在挂载盘下执行,最好在系统目录下执行。在问题1的情况下,config.h里面的内容也是不正确的。
解决问题1后,会出现问题2


问题2,在make时出现错误
libtool: link: arm-linux-gcc-4.3.5 -DGCC_HASCLASSVISIBILITY -O2 -Wall -W -o .libs/ts_test ts_test.o fbutils.o font_8x8.o font_8x16.o ../src/.libs/libts.so -ldl -Wl,-rpath -Wl,/opt/tslib-1.0/lib
fbutils.o: In function `open_framebuffer':
fbutils.c:(.text+0xa68): undefined reference to `rpl_malloc'
collect2: ld returned 1 exit status
make[2]: *** [ts_test] 错误 1
make[2]:正在离开目录 `/home/tslib-1.0/tests'
make[1]: *** [all-recursive] 错误 1
make[1]:正在离开目录 `/home/tslib-1.0'
make: *** [all] 错误 2
解决2,查找网络资料得知,此时的config.h里有下面的几句话:
/* Define to rpl_malloc if the replacement function should be used. */
#define malloc rpl_malloc
把上面的几句话删掉后重新编译,就正常了,交叉编译時autotools认为我的工具链的libc中不包含malloc和realloc,然后擅自做主张地替换成了rpl_malloc
gedit ./config.h


问题3,在make时出现错误
/bin/bash ../libtool --tag=CC --mode=compile arm-linux-gcc-4.3.5 -DHAVE_CONFIG_H -I. -I.. -DPLUGIN_DIR=\"\" -DTS_CONF=\"\" -MT ts_attach.lo -MD -MP -MF .deps/ts_attach.Tpo -c -o ts_attach.lo ts_attach.c
libtool: Version mismatch error. This is libtool 2.2.6b, but the
libtool: definition of this LT_INIT comes from libtool 2.2.10.
libtool: You should recreate aclocal.m4 with macros from libtool 2.2.6b
libtool: and run autoconf again.
make[2]: *** [ts_attach.lo] 错误 63
make[2]:正在离开目录 `/home/tslib-1.3/src'
make[1]: *** [all-recursive] 错误 1
make[1]:正在离开目录 `/home/tslib-1.3'
make: *** [all] 错误 2
解决3
运行 autoreconf -ivf 即可。但是在运行时,当前的这条命令也出现了问题
plugins/Makefile.am:12: `:='-style assignments are not portable

autoreconf -fiv
autoreconf --force --install


prefix后面是生成文件存放的目录,可以自定义,装好后修改/opt/tslib-1.0/etc/ts.conf 去掉module_raw input 前面的#号,然后把/opt/tslib-1.0里的文件都拷入开发

板,比如我放在了/usr/ts里。再配置开发板的环境变量,让/usr/ts/bin/ts_calibrate能正常运行,环境变量如下。

export PATH="$PATH:/usr/ts/bin"
export set LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/ts/lib"

export set TSLIB_TSDEVICE=/dev/input/event0
export set TSLIB_CONFFILE=/usr/ts/etc/ts.conf
export set TSLIB_CALIBFILE=/etc/pointercal
export set TSLIB_PLUGINDIR=/usr/ts/lib/ts



以上为必须配置
export set TSLIB_FBDEVICE=/dev/fb0
export set TSLIB_TSEVENTTYPE=H3600
export set TSLIB_CONSOLEDEVICE=none

问题1,如果执行过程中出现
./ts_calibrate: can't load library 'libts-0.0.so.0'
需要将 /usr/ts/lib 里的内容全部拷贝到系统/lib中 或export set LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/ts/lib"


问题2,如果执行过程中出现
ts_open: No such file or directory
需要修改 export set TSLIB_TSDEVICE=/dev/input/event0 ,确认触摸屏对应的设备为event0

问题3,如果执行过程中出现No raw modules loaded
修改/opt/tslib-1.0/etc/ts.conf 去掉module_raw input 前面的#号,
----------------------------------------------------------------------




----------------------------------------------------------------------
四 安装Qt4.8.5, 下载到的版本是 qt-everywhere-opensource-src-4.8.5.tar.gz
同样,先拷贝到/home 下,解压,配置,编译,安装,观察他的configue,用到了触摸屏的库文件等,
cp qt-everywhere-opensource-src-4.8.5.tar.gz /home
tar -xvzf qt-everywhere-opensource-src-4.8.5.tar.gz
cd /home/qt-everywhere-opensource-src-4.8.5


然后修改配置
gedit ./mkspecs/qws/linux-arm-g++/qmake.conf
把 linux-arm-g++/qmake.conf 里的linux-arm-g++ 改成交叉编译器 arm-linux-g++ ,linux-arm-gcc改成arm-linux-gcc-4.3.5 ,
另外添加下面两个ts的配置,
QMAKE_INCDIR=/opt/tslib-1.0/include
QMAKE_LIBDIR=/opt/tslib-1.0/lib
然后保存退出

然后是configure make install三步进行曲,config用config.sh,我已经把这个已经变成了脚本形式,放在配置库中,方便使用
./config.sh

必须在config里增加 -make libs ,否则会出现一些类似于缺少 -lbootstrap库的错误,上面的config.sh脚本已经包含

附录
./configure \
-prefix /usr/local/qt-4.6.2-arm \ (安装路径)
-opensource \ (自由版本)
-confirm-license \ (遵守协议yes)
-release \ (编译和连接QT时关闭调试)
-shared \ (使用QT动态库)
-embedded arm \ (嵌入式arm架构)
-xplatform qws/linux-arm-g++ \ (交叉编译时的目标平台)
-no-qt3support \ (关闭QT3支持功能)
-fast \ (只对库及子目录make来快速配置QT)
-no-largefile \ (使大文件支持无效)
-qt-mouse-tslib \ (使用tslib来驱动鼠标箭头运行,即支持触摸屏)
-I /usr/local/tslib/include \ (添加一个显式的include路径)
-L /uar/local/tslib/lib \ (添加一个显式的lib路径)
-make libs \ (构建lib库)
-make tools \ (构

建tools)
-nomake demos \ (不构建demos)
-nomake examples \(不构建examples)
-nomake docs \ (不构建docs)
-qt-libjpeg \ (使用jpeg库)
-qt-libpng \ (使用png库)
-qt-libtiff \ (使用tiff库)
-multimedia \ (构建QT多媒体模块)
-no-qvfb \ (不构建QVFB模块)
-no-svg \ (不构建SVG模块)
-no-cups \ (不编译CUPS支持)
-embedded 体系结构参数
QT为了更高的效率和线程安全。QT定义的原子操作,它跟各个平台高度相关。嵌入式平台必须配置这个参数,Configure用-embeded 写入Makefile.比如arm 就是 –embedded arm .
这个参数决定QtCore引用哪一个头文件,象ARM就引用 src/corelib/arch/qatomic_arm.h
-little-endian 字节序选项–big-endian
大部分采用 -little-endian (小端字节序)
-shared 编译动态版本
-prefix 编译好Qt库安装目录,默认目录是/usr/local/Trolltech/QtEmbedded-4.6.3 ,这里设为
-prefix /opt/QtEmbedded-4.5.3 (注意没有=)
-D ........增加宏定义
-I ........ 增加外部头文件引用目录
-L ........ 增加外部库路径

这个指QT库中哪一些不被编译,这一类参数以 --nomake 来指定
如 –nomake examples –nomake demos ,这个以节约编译时间。

相反的指定哪一部分编译用 –make 如 -make libs

如果QT的扩展库则直接采用名字来指明。
-no-XXX表示不编译某一些库, -no-phonon 不编译 phonon库,则对应的 –phonon就编译它。类似参数有。
[-no-dbus] [-dbus] [-no-svg] [-svg] [-no-webkit] [-webkit]

QT作为一个跨平台的函数,必然大量引用第三方库,在嵌入式平台上,必须要有选择指定使用第三方案。
一般有三种情况。
1).QT已经把大量第三方库源码放在src/3rdparty目录下。用 -qt-XXXX参数指定,如 -qt-libpng 表示用QT自己目录下的libpng源码编译,这种方法比较省心,并且出错可能少。
2).使用操作系统中已经编译好第三方库,用-system-XXX参数指定,如-system-libjpeg 表示用系统中编译好的libjpeg库,这里需要与 –I,-L两个参数来指定相应头文件和库路径。
3).不编译,使用-no-XXX来指定 ,如-no-cups,不编译cups打印支持。


问题1
在configue时,会有如下提示,
Type 'c' if you want to use the Commercial Edition.
Type 'o' if you want to use the Open Source Edition.
解决1 输入o回车,然后会有用户使用协议,输入yes表示同意,开始配置。

问题2 过一段时间后会出现下列信息,
You have not explicitly asked to use pkg-config and are cross-compiling.
pkg-config will not be used to automatically query cflag/lib parameters for
dependencies
The tslib functionality test failed!
You might need to modify the include and library search paths by editing
QMAKE_INCDIR and QMAKE_LIBDIR in
/home/qt-everywhere-opensource-src-4.8.5/mkspecs/qws/linux-arm-g++.



解决2 根据上述提示,需要添加两个配置
gedit /home/qt-everywhere-opensource-src-4.8.5/mkspecs/qws/linux-arm-g++/qmake.conf
QMAKE_INCDIR=/opt/tslib-1.0/include
QMAKE_LIBDIR=/opt/tslib-1.0/lib
另外还需要将 tslib-1.0/bin 添加到系统目录中
export PATH="$PATH:/opt/tslib-1.0/bin"
export PATH="$PATH:/home/qt-everywhere-opensource-src-4.8.5/mkspecs/qws/linux-arm-g++"

问题3
Basic XLib functionality test failed!
You might need to modify the include and library search paths by editing
QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11 in /home/qt-everywhere-opensource-src-4.8.5/mkspecs/linux-g++.
解决3
还是老办法,以不变应万变。进config.test / x11/xlib 执行make命令,看出错信息
g++ -Wl,-O1 -o xlib xlib.o -L/usr/X11R6/lib -lXext -lX11 -lm
/usr/bin/ld: cannot find -lXext
看到了吧,g++在/usr/X11R6/lib下,找不到libXext.so呢。
其原因就在于需要安装libX11的开发包,在ubuntu/debian里包名都是libX11-dev
根据以往的经验,在./configure前主动装好下面3个包,基本上就万事大吉了,执行下列命令,需要通过网络下载一些必要的组件,虚拟机的联网可以通过设置 网络模式为NAT:Used to share the host's IP address来实现
sudo apt-get install libX11-dev libXext-dev libXtst-dev


直到出现下列提示表示config已经成功
Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into /opt/qt-4.8.5-arm

To reconfigure, run 'make confclean' and 'configure'.

然后执行make ,估计需要1小时左右
make

问题1 make 后出现下列提示
In file included from animation/qabstractanimation.cpp:1057:
../../include/QtCore/../../src/corelib/arch/qatomic_i386.h: In destructor 'QWeakPointer::~QWeakPointer() [with T = QAbstractAnimation]':
../../include/QtCore/../../src/corelib/arch/qatomic_i386.h:132: error: impossible constraint in 'asm'
make[1]: *** [.obj/release-shared/qabstractanimation.o] 错误 1
make[1]:正在离开目录 `/home/qt-everywhere-opensource-src-4.8.5/src/corelib'
make: *** [sub-corelib-make_default-ordered] 错误 2
解决1 需要把 linux-arm-g++/qmake.conf 里的linux-arm-g++ 改成交叉编译器 arm-none-linux-gnueabi-g++ ,gcc改成gcc-4.2.3 保存退出


问题2 make 后出现下列提示
socket/qnativesocketengine_unix.cpp: In member function 'bool QNativeSocketEnginePrivate::nativeSetMulticastInterface(const QNetworkInterface&)':
socket/qnativesocketengine_unix.cpp:725: error: 'IPV6_MULTICAST_IF' was not declared in this scope
make[1]: *** [.obj/release-shared-emb-arm/qnativesocketengine_unix.o] 错误 1
make[1]:正在离开目录 `/home/qt-everywhere-opensource-src-4.8.5/src/network'
make: *** [sub-network-make_default-ordered] 错误 2
解决2 这些宏定义都在myipv6level.h 文件中,将此文件拷贝到qnativesocketengine_unix.cpp 所在的目录中
cp /mnt/hgfs/CCU/QT移植相

关/myipv6level.h ./src/network/socket
然后修改 gedit ./src/network/socket/qnativesocketengine_unix.cpp 增加头文件 #include "myipv6level.h"

问题3 make时出现下列错误提示
../3rdparty/javascriptcore/JavaScriptCore/assembler/MacroAssemblerARM.h:844: instantiated from here
../3rdparty/javascriptcore/JavaScriptCore/wtf/Vector.h:473: warning: cast from 'QTWTF::AlignedBufferChar*' to 'QTJSC::AbstractMacroAssembler::Jump*' increases required alignment of target type
make[1]: *** [obj/release/Collector.o] 错误 1
make[1]:正在离开目录 `/home/qt-everywhere-opensource-src-4.8.5/src/script'
make: *** [sub-script-make_default-ordered] 错误 2
解决3 在configure 时增加 下列选项
-no-javascript-jit . Do not build the JavaScriptCore JIT compiler.
-no-script ......... Do not build the QtScript module.
-no-scripttools .... Do not build the QtScriptTools module.


make成功后,make install
make install


++++++++++++++++++++vi /etc/profile++++++++++++++++++++
export PATH="$PATH:/usr/ts/bin"
export set LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/ts/lib"

export set TSLIB_TSDEVICE=/dev/input/event0
export set TSLIB_CONFFILE=/usr/ts/etc/ts.conf
export set TSLIB_CALIBFILE=/etc/pointercal
export set TSLIB_PLUGINDIR=/usr/ts/lib/ts

export set QTDIR=/usr/qt-4.8.5-arm
export set LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export set QT_QWS_FONTDIR=$QTDIR/lib/fonts/
export set QWS_SIZE=800x600
export set QWS_DISPLAY="LinuxFb:mmWidth80:mmHeight120:0"
export set QWS_DISPLAY="LinuxFB:/dev/fb0"
export set QT_PLUGIN_PATH=$QTDIR/plugins/
export set QWS_KEYBOARD="TTY:/dev/tty1"
export set QWS_MOUSE_PROTO="TSLIB:/dev/input/event0"
export PATH=$QTDIR/bin:$PATH
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

然后拷贝编译目录下的所有文件到系统目录的/usr下
tar -xvzf qt.tgz
export set LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/qt-4.8.5-arm/lib/"


----------------------------------------------------------------------







----------------------------------------------------------------------
五 编译dtv1000w ccu程序

早先gcc4.2.3的编译方式如下:
拷贝 DTV0413.tar.gz 到home下
cp /mnt/hgfs/CCU/QT移植相关/make86/DTV0413.tar.gz /home/
tar -xvzf DTV0413.tar.gz

//添加GCC4.2.3
cp arm-none-linux-gnueabi-gcc-4.2.3.tar.bz2 /home
tar -xvjf arm-none-linux-gnueabi-gcc-4.2.3.tar.bz2
export PATH="$PATH":/home/arm-2008q1/bin
export 命令查看当前所有的附加路径
vi /etc/profile 将下列命令添加到配置文件,以便重启后不丢失export PATH="$PATH":/home/arm-2008q1/bin

切换到CCU主目录下
cd /mnt/hgfs/CCU/prj/
make




上面是之前的gcc4.2.3的编译方式,现在需要采用4.3.5编译
修改MakeFile文件
CC = /home/DTV1000/arm-2008q1/bin/arm-none-linux-gnueabi-gcc -w
CXX = /home/DTV1000/arm-2008q1/bin/arm-none-linux-gnueabi-g++ -w
LINK

= /home/DTV1000/arm-2008q1/bin/arm-none-linux-gnueabi-g++
AR = /home/DTV1000/arm-2008q1/bin/arm-none-linux-gnueabi-ar cqs

改为
CC = arm-linux-gcc-4.3.5 -w
CXX = arm-linux-g++ -w
LINK = arm-linux-g++
AR = arm-linux-ar cqs

然后make


问题1
/home/AT9x25/buildroot-2011.05/output/host/usr/lib/gcc/arm-unknown-linux-uclibcgnueabi/4.3.5/../../../../arm-unknown-linux-uclibcgnueabi/bin/ld: cannot find -lts
collect2: ld returned 1 exit status
make: *** [prj] 错误 1


解决1 如果去除MakeFile文件中的
LIBS = $(SUBLIBS) -L/home/DTV1000/install/lib -lQtGui -L/home/DTV1000/install/lib -lts -lQtNetwork -lQtCore -lm -lrt -ldl -lpthread
中的 -lts,结果就出现下面的错误
/home/AT9x25/buildroot-2011.05/output/host/usr/lib/gcc/arm-unknown-linux-uclibcgnueabi/4.3.5/../../../../arm-unknown-linux-uclibcgnueabi/bin/ld: warning: libts-0.0.so.0, needed by /home/DTV1000/install/lib/libQtGui.so, not found (try using -rpath or -rpath-link)
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `ts_read_raw'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `ts_open'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `ts_fd'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `ts_config'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `ts_close'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `ts_read'
collect2: ld returned 1 exit status
make: *** [prj] 错误 1
由此可见,需要libts-0.0.so.0,-lts其实是引用ts库编译的意思,需要将ts库添加到-rpath所对应的lib中,
查看MakeFile文件有一句 LFLAGS = -Wl,-O1 -Wl,-rpath,/home/DTV1000/install/lib,可见编译时采用的是这个lib
cp -rf /opt/tslib-1.0/lib/* /home/DTV1000/install/lib/


问题2 出现类型下列的错误
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `ioctl@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `mmap@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `dup2@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `execv@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `dlsym@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `waitpid@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `__pthread_unregister_cancel@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `_exit@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `__assert_fail@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `pthread_mutex_unlock@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `logf@GLIBC_2.4'
/home/DTV1000/install/lib/libQtNetwork.so: undefined reference to `recv@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `isal

num@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `pthread_setcancelstate@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `ceilf@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `pthread_create@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `semop@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `signal@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `__tzname@GLIBC_2.4'
/home/DTV1000/install/lib/libQtNetwork.so: undefined reference to `sendto@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `pow@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `munmap@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `listen@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `raise@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `setlocale@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `backtrace@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `rand_r@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `getpagesize@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `readdir_r@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `popen@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `cfsetospeed@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `strcpy@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `fread@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `__fxstat@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `inotify_add_watch@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `strstr@GLIBC_2.4'
/home/DTV1000/install/lib/libQtNetwork.so: undefined reference to `gethostname@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `strerror@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `time@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `log10@GLIBC_2.4'
/home/DTV1000/install/lib/libQtNetwork.so: undefined reference to `gai_strerror@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `isalpha@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `fwrite@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `bind@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `isspace@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `feholdexcept@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `calloc@GLIBC_2.4'
/home/DTV1000/install/lib/libQtNetwork.so: undefined reference to `getsockopt@GLIBC_2.4'
/home/DTV1000/

install/lib/libQtGui.so: undefined reference to `snprintf@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `mremap@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `pthread_cond_init@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `strncpy@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `localtime_r@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `usleep@GLIBC_2.4'
/home/DTV1000/install/lib/libQtCore.so: undefined reference to `clock_gettime@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `tcsetattr@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `__aeabi_atexit@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `free@GLIBC_2.4'
/home/DTV1000/install/lib/libQtGui.so: undefined reference to `getuid@GLIBC_2.4'
/home/DTV1000/install/lib/libQtNetwork.so: undefined reference to `getaddrinfo@GLIBC_2.4'
collect2: ld returned 1 exit status
make: *** [prj] 错误 1

解决2 修改MakeFile文件中 LFLAGS 和 LIBS 的引用路径
qtlib = /opt/qt-4.8.5-arm/lib/
#/home/DTV1000/install/lib
LFLAGS = -Wl,-O1 -Wl,-rpath,$(qtlib)
LIBS = $(SUBLIBS) -L$(qtlib) -lQtGui -L$(qtlib) -lts -lQtNetwork -lQtCore -lm -lrt -ldl -lpthread


编译通过后运行程序:
./prj -qws
----------------------------------------------------------------------


6 回顾:
先将 QT移植相关 中的qt.tgz 拷贝到/opt/ 目录中解压缩
tar -xvzf qt.tgz
完成后会出现qt-4.8.5-arm目录
然后执行
export QMAKESPEC=/opt/qt-4.8.5-arm/mkspecs/qws/linux-arm-g++
并添加到profile中
gedit /etc/profile 或
vi /etc/profile

cp -rf ../QT移植相关/tslib-1.0.tgz /opt
tar -xvzf tslib-1.0.tgz
cp -rf /opt/tslib-1.0/lib/* /opt/qt-4.8.5-arm/lib

编译CCU时,先切换到prj目录
然后执行/opt/qt-4.8.5-arm/bin/qmake
然后make即可


问题1,出现下列错误提示
root@ubuntu:/mnt/hgfs/code/1KW_CCU/prj# ../QT移植相关/qt-4.8.5-arm/bin/qmake
QMAKESPEC has not been set, so configuration cannot be deduced.
Error processing project file: /mnt/hgfs/code/1KW_CCU/prj/prj.pro

root@ubuntu:/mnt/hgfs/code/1KW_CCU/prj# ../QT移植相关/qt-4.8.5-arm/bin/qmake
Failure to read QMAKESPEC conf file /home/AT9x25/buildroot-2011.05/output/host/usr/bin/arm-linux-g++/qmake.conf.

解决1
运行
export QMAKESPEC=../QT移植相关/qt-4.8.5-arm/mkspecs/qws/linux-arm-g++

export QMAKESPEC=/opt/qt-4.8.5-arm/mkspecs/qws/linux-arm-g++
并添加到profile中
vi /etc/profile

问题2:
/home/AT9x25/buildroot-2011.05/output/host/usr/lib/gcc/arm-unknown-linux-uclibcgnueabi/4.3.5/../../../../arm-unknown-linux-uclibcgnueabi/bin/ld: cannot find -lQtGui
/home/AT9x25/buildroot-2011.05/output/host/usr/lib/gcc/arm-unknown-linux-uclibcgnueabi/4.3.5/../../../../arm-unknown-linux-uclibcgnueabi/bin/ld: cannot find -lQtNetwork
/hom

e/AT9x25/buildroot-2011.05/output/host/usr/lib/gcc/arm-unknown-linux-uclibcgnueabi/4.3.5/../../../../arm-unknown-linux-uclibcgnueabi/bin/ld: cannot find -lQtCore
解决2:
cd /opt/qt-4.8.5-arm/lib/
ln -sv libQtGui.so.4.8.5 libQtGui.so
ln -sv libQtNetwork.so.4.8.5 libQtNetwork.so
ln -sv libQtCore.so.4.8.5 libQtCore.so


问题3:
/opt/qt-4.8.5-arm/bin/uic ../ui/windmanualctl.ui -o ui_windmanualctl.h
make: /opt/qt-4.8.5-arm/bin/uic:命令未找到
make: *** [ui_windmanualctl.h] 错误 127
解决3:
先将 QT移植相关 中的qt.tgz 拷贝到/opt/ 目录中解压缩
tar -xvzf qt.tgz
完成后会出现qt-4.8.5-arm目录
然后执行
export QMAKESPEC=/opt/qt-4.8.5-arm/mkspecs/qws/linux-arm-g++
并添加到profile中
gedit /etc/profile 或
vi /etc/profile



问题4:
/opt/qt-4.8.5-arm/lib/libQtGui.so: undefined reference to `ts_read_raw'
/opt/qt-4.8.5-arm/lib/libQtGui.so: undefined reference to `ts_open'
/opt/qt-4.8.5-arm/lib/libQtGui.so: undefined reference to `ts_fd'
/opt/qt-4.8.5-arm/lib/libQtGui.so: undefined reference to `ts_config'
/opt/qt-4.8.5-arm/lib/libQtGui.so: undefined reference to `ts_close'
/opt/qt-4.8.5-arm/lib/libQtGui.so: undefined reference to `ts_read'
collect2: ld returned 1 exit status
make: *** [prj] 错误 1
解决4:
cp -rf ../QT移植相关/tslib-1.0.tgz /opt
查看MakeFile文件有一句 LFLAGS = -Wl,-O1 -Wl,-rpath,/opt/qt-4.8.5-arm/lib,可见编译时采用的是这个lib
cp -rf /opt/tslib-1.0/lib/* /opt/qt-4.8.5-arm/lib


tar -xvzf tslib-1.0.tgz

相关主题