Qt5.4(later)树莓派2 交叉编译环境搭建
2015-07-31 16:04
435 查看
费了好大力气,终于把Qt5的交叉环境搞定了,这里记录一下具体的实现过程。google出来的文章都是很老的移植方法,很多博文里面
提供的下载链接均已失效。
* 2015-02-16-raspbian-wheezy.zip
* cross-compile-tools-master.zip
* gcc-4.7-linaro-rpi-gnueabihf.tbz
树莓派raspbian和qt5.4的源码都可以非常容易下载到,这里分享交叉编译链的网盘地址:
http://pan.baidu.com/s/1ntILnmT
提取码:x5dz
对于ubuntu14.02的64位系统,要添加32位库的支持,执行:
$ sudo apt-get install ia32-libs
如果你的系统比较老一点(题主的是Ubuntu12.02),z执行如下:
$ sudo apt-get install g++-multilib ia32-libs
ROOTFS_MOUNT=/mnt/rasp-pi-rootfs
WORKDIR=~/qt5rpi
$ sudo mkdir $PREFIX
$ sudo mkdir $ROOTFS_MOUNT
$ sudo tar xvf qt-everywhere-opensource-src-5.tar
$ sudo unzip 2015-02-16-raspbian-wheezy.zip
$ sudo unzip cross-compile-tools-master.zip
$ sudo tar -xjf gcc-4.7-linaro-rpi-gnueabihf.tbz
上述指令中,有两点需要注意容易出错:
* loop,offset 之间,不能出现空格
* offset该等于多少?执行命令
$sudo fdisk -l 2015-02-16-raspbian-wheezy.img
执行结果:
Device Boot Start End Blocks Id
System
2015-02-16-raspbian-wheezy.img1 8192 122879 57344 c
W95 FAT32 (LBA)
2015-02-16-raspbian-wheezy.img2 122880 6399999 3138560 83 Linux
offset=(512* 122880) ,这样就不会出错了。
git clone git://gitorious.org/cross-compile-tools/cross-compile-tools.git
这个地方下载,但是这个网站已经蹦掉了,有热心的老大重新把他上传到了github上,新的地址为:
https://github.com/shahriman/cross-compile-tools
执行如下指令:
$ cd cross-compile-tools-master
$ sudo ./fixQualifiedLibraryPaths $ROOTFS_MOUNT $WORKDIR/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc
$ ./configure -opengl es2 \
-device rasp-pi-g++ \
-device-option CROSS_COMPILE=$WORKDIR/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf- \
-sysroot $ROOTFS_MOUNT \
-opensource -confirm-license \
-optimized-qmake -reduce-exports -release -nomake tests \
-prefix $PREFIX -no-pch -skip qttools
$ sudo make -j4
$ sudo make install
等待编译完成,需要一定时间
cd $WORKDIR/qt-everywhere-opensource-src-5
for MODULE in qtimageformats qtsvg qtscript qtxmlpatterns qtdeclarative qtsensors qtgraphicaleffects qtlocation qtserialport qttools qtquick1 qtquickcontrols
do
cd $MODULE
$PREFIX/bin/qmake .
make -j4
sudo make install
cd ..
done
如上步骤可以组成一个完整的shell脚本,请自行实验
提供的下载链接均已失效。
1. 准备工具
* qt-everywhere-opensource-src-5.4.1.tar* 2015-02-16-raspbian-wheezy.zip
* cross-compile-tools-master.zip
* gcc-4.7-linaro-rpi-gnueabihf.tbz
树莓派raspbian和qt5.4的源码都可以非常容易下载到,这里分享交叉编译链的网盘地址:
http://pan.baidu.com/s/1ntILnmT
提取码:x5dz
对于ubuntu14.02的64位系统,要添加32位库的支持,执行:
$ sudo apt-get install ia32-libs
如果你的系统比较老一点(题主的是Ubuntu12.02),z执行如下:
$ sudo apt-get install g++-multilib ia32-libs
2. 预定义路径和文件名
PREFIX= /usr/local/qt5ROOTFS_MOUNT=/mnt/rasp-pi-rootfs
WORKDIR=~/qt5rpi
$ sudo mkdir $PREFIX
$ sudo mkdir $ROOTFS_MOUNT
3. 解压他们
为了方便说明,先下面的压缩文件均放置在$WORKDIR中$ sudo tar xvf qt-everywhere-opensource-src-5.tar
$ sudo unzip 2015-02-16-raspbian-wheezy.zip
$ sudo unzip cross-compile-tools-master.zip
$ sudo tar -xjf gcc-4.7-linaro-rpi-gnueabihf.tbz
4. 挂载下载好的最新Raspbian
$ sudo mount -o loop,offset=62914560 2015-02-16-wheezy-raspbian.img $ROOTFS_MOUNT上述指令中,有两点需要注意容易出错:
* loop,offset 之间,不能出现空格
* offset该等于多少?执行命令
$sudo fdisk -l 2015-02-16-raspbian-wheezy.img
执行结果:
Device Boot Start End Blocks Id
System
2015-02-16-raspbian-wheezy.img1 8192 122879 57344 c
W95 FAT32 (LBA)
2015-02-16-raspbian-wheezy.img2 122880 6399999 3138560 83 Linux
offset=(512* 122880) ,这样就不会出错了。
5. 使用cross-compile-tools进行目录配置
cross-compile-tools-master.zip目前大部分对Qt5进行移植的教程都是从:git clone git://gitorious.org/cross-compile-tools/cross-compile-tools.git
这个地方下载,但是这个网站已经蹦掉了,有热心的老大重新把他上传到了github上,新的地址为:
https://github.com/shahriman/cross-compile-tools
执行如下指令:
$ cd cross-compile-tools-master
$ sudo ./fixQualifiedLibraryPaths $ROOTFS_MOUNT $WORKDIR/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc
6. 编译qtbase
$ cd $WORKDIR/qt-everywhere-opensource-src-5/qtbase$ ./configure -opengl es2 \
-device rasp-pi-g++ \
-device-option CROSS_COMPILE=$WORKDIR/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf- \
-sysroot $ROOTFS_MOUNT \
-opensource -confirm-license \
-optimized-qmake -reduce-exports -release -nomake tests \
-prefix $PREFIX -no-pch -skip qttools
$ sudo make -j4
$ sudo make install
等待编译完成,需要一定时间
7. 编译其他的qt模块
用一个小的shell脚本:cd $WORKDIR/qt-everywhere-opensource-src-5
for MODULE in qtimageformats qtsvg qtscript qtxmlpatterns qtdeclarative qtsensors qtgraphicaleffects qtlocation qtserialport qttools qtquick1 qtquickcontrols
do
cd $MODULE
$PREFIX/bin/qmake .
make -j4
sudo make install
cd ..
done
8. 配置QtCreator
这个不是本文的范畴,编译都没问题了,后面的资料好查找。如上步骤可以组成一个完整的shell脚本,请自行实验
相关文章推荐
- qtcreator 交叉编译 配置
- 关于Qt的MVC
- Qt中定时器的使用
- Qt 5.3 下OpenCV 2.4.11 开发(7)单通道直方图绘制
- Qt归纳(四)
- Qt归纳(三)
- Qt归纳(二)
- Qt归纳(一)
- Qt重绘之update,repaint详解
- vs2013+qt+opencv3.0配置
- Qt - OpenCV的安装与配置 (win7 64 bit + OpenCV3.0 + minGW32)
- Qt获取组合键
- qt最简单的写文件代码linux最简单的写文件代码
- QT foreach 和 QTextCodec
- Qt以及Qt Designer怎样加入资源文件
- Qt窗体关闭时,如何自动销毁窗体类对象
- 使用Qt显示openCV矩阵图片
- Qt中QScrollArea的使用
- 使用Qt创建一个OpenCV工程
- QT在CT上的安装及运行