Qt4.8移植到Raspberry

Qt4.8移植到Raspberry主要分为两大步:

1.cross-compiler的建立

2.Qt4.8的交叉编译

 

具体移植步骤如下:

一、cross-compiler的建立

1.首先准备好PC机,本文用的是Ubuntu 12.04 LTS(装在虚拟机上)

2.Download crosstool-ng from the project web site. I’ve used version 1.15.2 as that was the latest when I wrote this.

 

3.Unpack the tarball and cd into the unpacked directory, then run ./configure --prefix=/opt/cross. You can pick somewhere else instead of /opt/cross but that’s where I like to keep it.

 

4.Run make and sudo make install.

 

5.Make sure /opt/cross/bin is in your $PATH.

 

上面都是建立编译环境,然后是对ng工具进行配置,步骤如下:

  1. Create a directory somewhere in your home directory that crosstool-ng will use as a staging ground. This will contain your toolchain configuration, downloaded files, and intermediary build results. This is not where your final toolchain will end up, and does take up quite a lot of space (3.5GB and up for me). cd into your chosen directory.
  2. Run ct-ng menuconfig. You should see the ct-ng configuration menu.
  3. Go into Paths and misc options. Enable Try features marked as EXPERIMENTAL.This is important.
  4. While you’re there you may want to change your Prefix directory. I like to put all my toolchains in /opt/cross/x-tools/${CT_TARGET} instead of ${HOME}/x-tools/${CT_TARGET}.
  5. Go back to the main menu and select Target options.
  6. Change the Target architecture to arm. Leave Endianness set to Little endian andBitness set to 32-bit.
  7. Go back to the main menu and select Operating system (skip Toolchain options, the defaults are fine).
  8. Change Target OS to linux.
  9. Go back to the main menu and select Binary utilities.
  10. Change binutils version to 2.21.1a or whichever is the latest that isn’t marked as experimental. Probably unnecessary but I prefer this.
  11. Go back to the main menu and select C compiler.(这一步一定要同时勾选C++编译器,因为后面编译qt会用到)
  12. Enable the Show Linaro versions (EXPERIMENTAL) option.
  13. In the gcc version field, choose the linaro-4.6-2012.04 (EXPERIMENTAL) compiler. You’re free to choose a different one but I know this one works well. I do recommend the Linaro versions over the vanilla ones for the RPi.
  14. All the other settings are fine left at their default values. Exit the configuration tool and save your changes.
  15. Run ct-ng build.
  16. Go away and make a coffee, etc… This bit will take some time.
  17. You should end up with a freshly baked arm compiler ready for building kernels (and other things) for your Raspberry Pi in your Prefix directory you chose above.
  18. Just add your compiler directory to your $PATH and start compiling. If you used my preferred prefix directory, you would want to add /opt/cross/x-tools/arm-unknown-linux-gnueabi/bin.

(原文请参考链接http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/

 

二、Qt4.8的移植

步骤如下:

Building Qt 4.8 Embedded for the Raspberry Pi

These are the steps I went through to build Qt 4.8 for Embedded Linux for the Raspberry Pi.

Build a cross compiler

Follow the instructions on using CrossTool-NG. I used the latest version of CT-NG and chose the GCC, Binutils and Kernel Headers to match the tools on the RasPi. I also had to adjust the compiler support libraries to match, via a process of build, change versions, build, etc. It is also important to enable C++ under language support, as by default only the C compiler is built.
 Once you have built a cross compiler, I strongly recommend testing it by compiling a test program such as:

#include <iostream>
int main(int, char**)
{
  float a = 2.0f * 2.0f;
  std::cout << "Test " << a << std::endl;
  return 0;
}
 Once you have a cross compiler working, edit your ~/.bash_profile file and add the directory containing the tools to your PATH.

Build zLib and OpenSSL

If you want to be able to use SSL sockets, or access https websites, you will need to build zLib and OpenSSL. The instructions below are slightly modified from a post on StackOverflow about this.

  1. Download zLib and OpenSSL source packages and extract them.
  2. Set the following environment variables:
    export CC=`/bin/which arm-unknown-linux-gnueabi-gcc`
    export AR=`/bin/which arm-unknown-linux-gnueabi-ar`
    export RANLIB=`/bin/which arm-unknown-linux-gnueabi-ranlib`
    
  3. Build zLib
    cd zlib-1.2.7
    ./configure --prefix=/opt/raspi
    make
    sudo make install
    
  4. Build OpenSSL
    cd openssl-1.0.1e
    ./Configure linux-elf zlib -L/opt/raspi/lib -I/opt/raspi/include --prefix=/opt/raspi no-asm
    make
    sudo make install
    

Build Qt

Download and extract Qt for Embedded Linux.

Edit the file in  mkspecs/qws/linux-arm-gnueabi-g++/qmake.conf and change the names of the tools to match (mine had built with 'unknown' and not 'none' in the name).

Run the following to build it:

./configure -embedded arm -qt-freetype -prefix /opt/raspi -xplatform qws/linux-arm-gnueabi-g++ -I/opt/raspi/include -L/opt/raspi/lib -no-cups -qt-zlib -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -no-javascript-jit -no-qt3support -qt-gfx-linuxfb -qt-gfx-transformed -plugin-gfx-vnc -qt-kbd-tty -qt-kbd-linuxinput -qt-mouse-pc -qt-mouse-linuxinput -openssl

make -j 8
sudo make install

Whilst building I encountered the following problems:
  • Error message:
    fatal error: .pch/release-shared-emb-arm/QtGui: No such file or directory

    This can be fixed by running:
    touch src/gui/.pch/release-shared-emb-arm/QtGui
    
  •  Error message whilst compiling SerializedScriptValue.o This can be fixed by going in to the directory where it is building (src/3rdparty/webkit/Source/WebCore) and re-running the failed call to g++ but with the -O2 flag changed to -O1
Once it has built, you can copy the /opt/raspi directory on to the RasPi, make sure you put it in the same place.

Testing

On the RasPi, before running the demo programs, you need to set the keyboard driver to use with:
export QWS_KEYBOARD=linuxinput

You can then run the demo browser with:

/opt/raspi/demos/browser/browser -qws

 

原文(http://skyhisi.blogspot.com/2013/03/building-qt-48-embedded-for-raspberry-pi.html

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值