从PC编译到ARM的Qt库
来源:互联网 发布:北京seo外包服务 编辑:程序博客网 时间:2024/05/19 19:40
实验目的
学会QT在ARM设备上的移植方法与步骤
实验环境
实验机:Fedora14
Qt库版本:
qt-everywhere-opensource-src-4.8.5.tar.gz
交叉编译器:
arm-linux-gcc-4.3.2.tgz
触屏包:
tslib-1.4.tar.bz2
实验内容
一、安装arm-linux-gcc交叉编译器
a)进入/usr/local下建立arm文件夹
[root@localhost /]# cd /usr/local
[root@localhost local]# mkdir arm
b)解压arm-linux-gcc
[root@localhost arm]#tar -zxvf arm-linux-gcc-4.3.2.tgz
c)添加环境变量
[root@localhost ~]# gedit .bashrc
export PATH=/usr/local/arm/4.3.2/bin:$PATH
[root@localhost ~]# source .bashrc
d)查看arm-linux-gcc是否安装成功
[root@localhost ~]# arm-linux-gcc -v
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /scratch/julian/lite-respin/linux/src/gcc-4.3/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --enable-shared --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery G++ Lite 2008q3-72' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/julian/lite-respin/linux/install/arm-none-linux-gnueabi/libc --with-gmp=/scratch/julian/lite-respin/linux/obj/host-libs-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/julian/lite-respin/linux/obj/host-libs-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/julian/lite-respin/linux/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/julian/lite-respin/linux/install/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72)
二、安装tslib触屏包
a) 解压
[root@localhost test]#tar –xjvf tslib-1.4.tar.bz2
b) 使用autogen.sh建立configure
[root@localhost test]#./autogen.sh
c)使用configure建立makefile
[root@localhost test]#./configure --host=arm-none-linux-gnueabi --cache-file=arm-none-linux-gnueabi.cache --enable-inputapi=no -- prefix=/usr/local/arm-linux/tslib1.4
d)编译tslib库
Make
出现错误:undefined reference to `rpl_malloc'
编译tslib,执行make时提示undefined reference to `rpl_malloc'
是因为config.h.in文件中有
/* Define to rpl_malloc if the replacement function should be used. */
#undef malloc
把#undef malloc注释掉重新make即可
e)安装tslib到指定目录
make install
三、交叉编译Qt库
a)解压
[root@localhost local]# tar -zxvf qt-everywhere-opensource-src-4.8.5.tar.gz
b)交叉编译
./configure -embedded arm -xplatform qws/linux-arm-gnueabi-g++ -nomake demos -nomake examples -no-stl -no-qt3support -no-phonon -no-svg -no-webkit -no-openssl -no-nis -no-cups -no-iconv -no-pch -no-dbus -no-separate-debug-info -fast -little-endian -qt-mouse-linuxtp -qt-mouse-tslib -I /usr/local/arm-linux/tslib1.4/include -L/usr/local/arm-linux/tslib1.4/lib -prefix /usr/local/Trolltech/Qt_4.8.5
提示并依次输入o(opensource的o) yes
c)make
d)make install
e)配置环境变量
[root@localhost local]# gedit /etc/profile
添加环境变量如下:
export PATH="/usr/local/Trolltech/Qt-embedded-4.8.5/bin:$PATH"
下面测试一下:
mkdir test
cd test
vim main.cpp
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv)
{
QApplication app(argc,argv);
QLabel *label = new QLabel("hello!");
label->show();
return app.exec();
}
[root@localhost hello]# ls
main.cpp
[root@localhost hello]# qmake -project
[root@localhost hello]# ls
hello.pro main.cpp
[root@localhost hello]# qmake hello.pro
[root@localhost hello]# ls
hello.pro main.cpp Makefile
[root@localhost hello]# make
arm-none-linux-gnueabi-g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-embedded-4.8.5/mkspecs/qws/linux-arm-gnueabi-g++ -I. -I/usr/local/Trolltech/Qt-embedded-4.8.5/include/QtCore -I/usr/local/Trolltech/Qt-embedded-4.8.5/include/QtNetwork -I/usr/local/Trolltech/Qt-embedded-4.8.5/include/QtGui -I/usr/local/Trolltech/Qt-embedded-4.8.5/include -I. -I. -o main.o main.cpp
arm-none-linux-gnueabi-g++ -Wl,-O1 -Wl,-rpath,/usr/local/Trolltech/Qt_4.8.5/lib -o hello main.o -L/usr/local/Trolltech/Qt-embedded-4.8.5/lib -lQtGui -L/usr/local/arm-linux/tslib1.4/lib -L/usr/local/Trolltech/Qt-embedded-4.8.5/lib -lQtNetwork -lQtCore -lpthread
/usr/local/arm/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/bin/ld: warning: libts-0.0.so.0, needed by /usr/local/Trolltech/Qt-embedded-4.8.5/lib/libQtGui.so, not found (try using -rpath or -rpath-link)
/usr/local/Trolltech/Qt-embedded-4.8.5/lib/libQtGui.so: undefined reference to `ts_read_raw'
/usr/local/Trolltech/Qt-embedded-4.8.5/lib/libQtGui.so: undefined reference to `ts_open'
/usr/local/Trolltech/Qt-embedded-4.8.5/lib/libQtGui.so: undefined reference to `ts_fd'
/usr/local/Trolltech/Qt-embedded-4.8.5/lib/libQtGui.so: undefined reference to `ts_config'
/usr/local/Trolltech/Qt-embedded-4.8.5/lib/libQtGui.so: undefined reference to `ts_close'
/usr/local/Trolltech/Qt-embedded-4.8.5/lib/libQtGui.so: undefined reference to `ts_read'
collect2: ld returned 1 exit status
make: *** [hello] 错误 1
错误原因:链接tslib库失败
解决方案:在Makefile文件下的LIB行添加-lts
[root@localhost hello]# gedit Makefile
LIBS = $(SUBLIBS) -L/usr/local/Trolltech/Qt-embedded-4.8.5/lib -lQtGui -L/usr/local/arm-linux/tslib1.4/lib -L/usr/local/Trolltech/Qt-embedded-4.8.5/lib -lQtNetwork -lQtCore -lpthread -lts
[root@localhost hello]# make
arm-none-linux-gnueabi-g++ -Wl,-O1 -Wl,-rpath,/usr/local/Trolltech/Qt_4.8.5/lib -o hello main.o -L/usr/local/Trolltech/Qt-embedded-4.8.5/lib -lQtGui -L/usr/local/arm-linux/tslib1.4/lib -L/usr/local/Trolltech/Qt-embedded-4.8.5/lib -lQtNetwork -lQtCore -lpthread -lts
[root@localhost hello]# ls
hello hello.pro main.cpp main.o Makefile
[root@localhost hello]#
- 从PC编译到ARM的Qt库
- PC和ARM平台编译Qt的命令
- 将PC版本的QT程序编译为ARM版本
- 从PC总线到ARM的内部总线
- 从PC总线到ARM的内部总线
- 从PC总线到ARM的内部总线 收藏
- 从PC总线到ARM的内部总线
- 从PC的总线到ARM内部总线
- 从PC的总线到ARM内部总线
- 从PC的总线到ARM内部总线
- 从PC的总线到ARM内部总线
- 从PC总线到ARM的内部总线
- 从PC总线到ARM的内部总线
- 从PC总线到ARM的内部总线
- 从PC的总线到ARM内部总线
- 从PC总线到ARM内部总线
- 编译QT到arm上
- Linux PC和ARM版的QT环境设置及到ARM移植&常见错误解决方法
- poj3264
- Struts2中的异常处理
- hive 实现不等连结
- Java常用类集接口以及实现方式总结
- Undefined symbols for architecture arm64:
- 从PC编译到ARM的Qt库
- 浅析SAX,DOM,JAXP,JDOM与DOM4J之间的关系
- 菜鸟版JAVA设计模式—从买房子看代理模式
- mysql查看表结构和表创建语命令
- tail
- 第一个Android的应用程序目录结构详说
- [POJ 1080]Human Gene Functions(动态规划)
- ormlite介绍一
- 无限级分类--获取子分类