2015年9月18日金曜日

LinuxMint 17.2にRaspberryPiのQtのクロス開発環境を入れる

LinuxMint 17.2にRaspberryPiのQtのクロス開発環境を入れる

LinuxMint 17.2 xfce 64bitの環境です。
RaspberryPi Beginners Guide - Qt Wiki
http://wiki.qt.io/RaspberryPi_Beginners_Guide
こちらのページにわかりやすく書いてあるのですが、英語なので読むのに時間がかかるので、日本語でメモしておきます。
説明のページでコマンドの例に示してあるURLはことごとくつながらないので、すぐ下に書いてあるミラーなどのページからダウンロードなりする必要がありました。

0. 前準備

必要なので、さきに入れておく。
ぜんぶapt-getで入ります。
git
g++
freeglut3-dev
(以下64bitの環境のみ)
ia32-libs
lib32z1
lib32ncurses5
lib32bz2-1.0

1. 必要なものをダウンロード

すべて、$HOME/optにダウンロードしたものとします。
  1. RaspbianのSDカードのイメージ
     Download Raspbian for Raspberry Pi
    https://www.raspberrypi.org/downloads/raspbian/
    2015-05-05-raspbian-wheezy.zip
  2. クロス環境を作るときに設定をしてくれるスクリプト類
  3. Qtのソース
    $git clone git://code.qt.io/qt/qt5.git
    $cd qt5
    $ ./init-repository

2. コンパイル

ラズパイのイメージのマウント

$unzip 2015-05-05-raspbian-wheezy.zip
$sudo mkdir /mnt/rasp-root
$sudo mount -o loop,offset=62914560 2015-05-05-raspbian-wheezy.img /mnt/rasp-root
offsetの値は以下のようにチェックする。同じイメージなら同じはずです。
$ fdisk -l 2015-05-05-raspbian-wheezy.img
Disk 2015-05-05-raspbian-wheezy.img: 879 MB, 879558656 bytes
255 heads, 63 sectors/track, 106 cylinders, total 1717888 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa6202af7
                     Device Boot      Start         End      Blocks   Id  System
2015-05-05-raspbian-wheezy.img1 8192 122879 57344 c W95 FAT32 (LBA)
2015-05-05-raspbian-wheezy.img2 122880 6399999 3138560 83 Linux
2つ目のパーティションをマウントしたいので、1セクター512なので、512*122880を飛ばしてマウントするいう意味です。
$cd cross-compile-tools
$sudo ./fixQualifiedLibraryPaths /mnt/rasp-root/ ~/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc
これで、環境に合わせて設定してくれます。
$cd ../qt5/qtbase
$./configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=~/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf- -sysroot /mnt/rasp-root -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /opt/qt5pi -hostprefix /opt/qt5pi
$make -j 4
$sudo make install
コンフィグのオプションで最後の -prefixがラズパイのイメージのどこに入れるかで、-hostprefixが母艦のどこに入れるかになります。
次はよくわかりません。必要なモジュールを個別に入れます。
qtimageformats, qtsvg, qtjsbackend, qtscript, qtxmlpatterns, qtdeclarative, qtsensors, qt3d, qtgraphicaleffects, qtjsondb, qtlocation, qtdocgallery
これだけあるみたいですが、自分はよくわからないので、全部入れました。
ディレクトリの中が空のものとかもあってよくわかりませんでした。
それぞれのディレクトリに移動して以下の用にコンパイルします。
$/opt/qt5pi/bin/qmake .
$make -j4
$sudo make install

3. イメージの書き込み

きちんとインストールされてるか確認をしてから、SDカードに書き込みます。
$ ls /mnt/rasp-root/opt/qt5pi
$sync
$sudo umount /mnt/rasp-root
sudo dd bs=1M if=2015-05-05-raspbian-wheezy.img of=/dev/sdb
of=/dev/sdbは環境によって異なるので、チェックしてから。
母艦で開発するときにイメージをマウントする必要があるので、消さないように注意する。

Qtcreatorの設定に続く

0 件のコメント:

コメントを投稿