emblog

webのチラ裏、linux、Qt関連はまった&はまってる事etc

RaspberryPi@Raspbian(wheezy)用にQt5beta1をCrossCompileする(その2)

RaspberryPiのRaspbian(wheezy)にて、Qt5beta1をCrossCompileする

Qt5beta1をRaspbian(wheezy)にてCrossCompileした時の覚書です。

前回の続きから

***環境構築Dir構成***

(諸事情でRaspberryPi_Beginners_guide | Qt Wiki | Qt Developer Networkと構築Dir先やDir名は変えています。)

/
|--/opt
|   '--/DeveloperTool
|   |  |--/Qt
|   |  |  '--/qt5-rpi-min/ - Qt5beta1 checkout先
|   |  '-- /RaspberryPi
|   |      '--/Raspbian    - Raspbian (wheezy)のimage置き場
|   '--/toolchain          - RaspberryPi用 Hardfloat CrossCompiler
/mnt
 '--/rpi-rootfs            - RaspberryPi用rootfsマウント先


***cross-compile-toolsの実行***

fixQualifiedLibraryPathsを使用します。
usage:
./cmd target-rootfs path-to-target-toolchain-compiler

$ cd /opt/DeveloperTool/RaspberryPi/Raspbian/cross-compile-tools
$ sudo ./fixQualifiedLibraryPaths /mnt/rpi-rootfs /opt/toolchain/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc

必ずsudoをつけて実行します。(/mnt/rpi-rootfs/内にてlibraryのシンボリックリンクを生成させる為)
OKな時のlog

Passed valid toolchain
Adjusting the symlinks in /mnt/rpi-rootfs/usr/lib to be relative
./libudev.so
../../lib/arm-linux-gnueabihf/libudev.so.0.13.0
Testing for existence of potential debian multi-arch dir: /mnt/rpi-rootfs/usr/lib/arm-linux-gnueabihf
Debian multiarch dir exists, adjusting
Adjusting the symlinks in /mnt/rpi-rootfs/usr/lib/arm-linux-gnueabihf to be relative
./libglib-2.0.so
../../../lib/arm-linux-gnueabihf/libglib-2.0.so.0
./libcidn.so
../../../lib/arm-linux-gnueabihf/libcidn.so.1
./libanl.so
../../../lib/arm-linux-gnueabihf/libanl.so.1
./libnss_nisplus.so
../../../lib/arm-linux-gnueabihf/libnss_nisplus.so.2
./libnss_nis.so
../../../lib/arm-linux-gnueabihf/libnss_nis.so.2
./libnss_compat.so
../../../lib/arm-linux-gnueabihf/libnss_compat.so.2
./libnss_files.so
../../../lib/arm-linux-gnueabihf/libnss_files.so.2
./libutil.so
../../../lib/arm-linux-gnueabihf/libutil.so.1
./libdbus-1.so
../../../lib/arm-linux-gnueabihf/libdbus-1.so.3.7.1
./libz.so
../../../lib/arm-linux-gnueabihf/libz.so.1.2.7
./libnss_dns.so
../../../lib/arm-linux-gnueabihf/libnss_dns.so.2
./libcrypt.so
../../../lib/arm-linux-gnueabihf/libcrypt.so.1
./libexpat.so
../../../lib/arm-linux-gnueabihf/libexpat.so.1.6.0
./libdl.so
../../../lib/arm-linux-gnueabihf/libdl.so.2
./libthread_db.so
../../../lib/arm-linux-gnueabihf/libthread_db.so.1
./libm.so
../../../lib/arm-linux-gnueabihf/libm.so.6
./libnsl.so
../../../lib/arm-linux-gnueabihf/libnsl.so.1
./libnss_hesiod.so
../../../lib/arm-linux-gnueabihf/libnss_hesiod.so.2
./librt.so
../../../lib/arm-linux-gnueabihf/librt.so.1
./libresolv.so
../../../lib/arm-linux-gnueabihf/libresolv.so.2
./libpcre.so
../../../lib/arm-linux-gnueabihf/libpcre.so.3
./libBrokenLocale.so
../../../lib/arm-linux-gnueabihf/libBrokenLocale.so.1

NGな時のlog
(sudo をつけないで実行した場合)

Passed valid toolchain
Adjusting the symlinks in /mnt/rpi-rootfs/usr/lib to be relative
Testing for existence of potential debian multi-arch dir: /mnt/rpi-rootfs/usr/lib/arm-linux-gnueabihf
Debian multiarch dir exists, adjusting
Adjusting the symlinks in /mnt/rpi-rootfs/usr/lib/arm-linux-gnueabihf to be relative

となり、あとのqtbaseのCompileにてerrorになります。(→やってしまった人...)

***Qt5のqtbaseチェックアウト***

今回は、qt5 in Qt - Qt by Nokiaから一気にQt5のリポジトリから
取得するのではなく、1つずつモジュールをmakeする事にし、最近ベータ版がリリースされたので、
v5.0.0-beta1のtagにてbuildを進めて行きます。
まずは、qtbaseをチェックアウトしてmakeしていく事にします。
qtbaseをgitから取得

$ mkdir -p /opt/DeveloperTool/Qt/qt5-rpi-min  /* Dir作成 */
$ cd /opt/DeveloperTool/Qt/qt5-rpi-min        /* Dir移動 */
$ git clone git://gitorious.org/qt/qtbase.git
$ cd ./qtbase/
$ git tag                                     /* tagを調べます */
qt-v5.0.0-alpha1
v5.0.0-beta1
/* v5.0.0-beta1 のタグでbranchを作ります */
$ git checkout -b branch-v5.0.0-beta1 v5.0.0-beta1 
Switched to a new branch 'branch-v5.0.0-beta1'
$ git branch                                 /* branchの確認 */
* branch-v5.0.0-beta1
  master

configureの実行

./configure -no-pch -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=/opt/toolchain/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf- -sysroot /mnt/rpi-rootfs -opensource -confirm-license -optimized-qmake -reduce-relocations -reduce-exports -release -make libs -prefix /usr/local/qt5rpi 2>&1 | tee ../qtbase_configure.log

configure logです。(詳細log)

Building on:   linux-g++-64
Building for:  devices/linux-rasp-pi-g++
Architecture:  arm, features:
Host architecture: x86_64, features: mmx sse sse2
Platform notes:

            - Also available for Linux: linux-kcc linux-icc linux-cxx
        
Build ..................  libs
Configuration ..........  cross_compile qpa largefile neon pcre  minimal-config small-config medium-config large-config full-config fontconfig libudev evdev linuxfb c++11 accessibility egl eglfs opengl opengles2 shared qpa reduce_exports reduce_relocations clock-gettime clock-monotonic mremap getaddrinfo ipv6ifname getifaddrs inotify png system-freetype system-zlib nis iconv glib gstreamer dbus openssl rpath icu concurrent audio-backend v8 release
Debug .................. no
C++11 support .......... yes
pkg-config ............. yes
QtDBus module .......... yes (run-time)
QtConcurrent code ...... yes
QtGui module ........... yes
QtWidgets module ....... yes
JavaScriptCore JIT ..... To be decided by JavaScriptCore
QML debugging .......... yes
PCH support ............ no
iWMMXt support ......... no
NEON support ........... yes
IPv6 ifname support .... yes
getaddrinfo support .... yes
getifaddrs support ..... yes
Accessibility .......... yes
NIS support ............ yes
CUPS support ........... no
Iconv support .......... yes
Glib support ........... yes
GStreamer support ...... yes
PulseAudio support ..... no
Large File support ..... yes
GIF support ............ plugin
JPEG support ........... plugin (qt)
PNG support ............ yes (qt)
zlib support ........... system
Session management ..... auto
libudev support ........ yes
OpenGL support ......... yes (OpenGL ES 2.x)
OpenVG support ......... no
XShape support ......... auto
XVideo support ......... auto
XSync support .......... auto
Xinerama support ....... runtime
Xcursor support ........ runtime
Xfixes support ......... runtime
Xrandr support ......... runtime
Xi support ............. runtime
Xi2 support ............ auto
MIT-SHM support ........ auto
FontConfig support ..... yes
XKB Support ............ auto
immodule support ....... yes
GTK theme support ...... no
SQLite support ......... plugin (qt)
OpenSSL support ........ yes (run-time)
Alsa support ........... no
libICU support ......... yes
PCRE support ........... qt
Xcb support ............ no
Xrender support ........ no
EGLFS support .......... yes
DirectFB support ....... no
LinuxFB support ........ yes
KMS support ............ no

makeの実行

$ make 2>&1 | tee ../qtbase_make.log

qtbase make logです。(詳細log)
Build Bad How to
僕のハマった内容です。

  • ハマりどころ1
qlibrary_unix.cpp:(.text+0xf84): warning: Using `dlopen' in statically linked applications requiresion used for linking
/mnt/rpi-rootfs/usr/lib/arm-linux-gnueabihf/libdl.a(dlopen.o): In function `dlopen':
/mnt/rpi-rootfs/usr/lib/arm-linux-gnueabihf/libdl.a(dlclose.o): In
function `dlclose':
(.text+0x0): undefined reference to `__dlclose'
/mnt/rpi-rootfs/usr/lib/arm-linux-gnueabihf/libdl.a(dlsym.o): In
function `dlsym':
(.text+0xc): undefined reference to `__dlsym'
/mnt/rpi-rootfs/usr/lib/arm-linux-gnueabihf/libdl.a(dlerror.o): In
function `dlerror':
(.text+0x0): undefined reference to `__dlerror'
/mnt/rpi-rootfs/usr/lib/arm-linux-gnueabihf/libm.a(feholdexcpt.o): In
function `feholdexcept':
(.text+0x48): undefined reference to `_dl_hwcap'
/mnt/rpi-rootfs/usr/lib/arm-linux-gnueabihf/libm.a(fesetenv.o): In
function `fesetenv':
(.text+0x64): undefined reference to `_dl_hwcap'
collect2: error: ld returned 1 exit status
make[2]: *** [../../lib/libQtCore.so.5.0.0] エラー 1
make[2]: Leaving directory `/opt/DeveloperTool/Qt/qt5-rpi-min/qtbase/src/corelib'
make[1]: *** [sub-corelib-make_first] エラー 2
make[1]: Leaving directory `/opt/DeveloperTool/Qt/qt5-rpi-min/qtbase/src'
make: *** [sub-src-make_first] エラー 2

→ ./fixQualifiedLibraryPathsが、sudoをつけずに実行した等により正常に実行されなかった場合にでる。

  • ハマりどころ2
cc1: fatal error: .pch/release-shared/QtGui: No such file or directory
or
cc1: fatal error: .pch/release-shared/QtGui: そのようなファイルやディレクトリがありません。

ここのTroubleshootingにあるように、configureにて“-no-pch”をつけなかった場合にでる。
installの実行
わたしの場合には、configureの-prefixにて、”/usr/local/qt5rpi”と設定しているため
/usr/local/qt5rpiにinstallされました。

$ sudo make install 2>&1 | tee ../qtbase_make_install_.log

(詳細log)

つっ疲れた...、次回にてQt5の残りのモジュールについて記載をしていきます。
next (その3)