'Cross Compile'에 해당되는 글 2건

  1. 2013.07.27 How to cross compile SDL for target arm board
  2. 2013.07.23 How to create qt5 app using CMake for Arm target board

This post is to show a real example for cross compiling SDL library for target arm board and include all necessary steps from downloading the library to installation of the compiled package to the root file system for target board.


For this real example, I worked with below settings.


Host machine: Ubuntu 12.04 x86-64 bit

HW: Beaglebone black(BBB) with 4GB uSD card

OS: Ubuntu 13.04 (http://rcn-ee.net/deb/rootfs/raring/ubuntu-13.04-console-armhf-2013-07-22.tar.xz)

Toolchain for cross compile: Refer to below Step 0.






For the first time you need to get prebuilt image for Ubuntu 13.04 version and prepare bootable SD card.


Step 0: Preparing toolchain and building Linux kernel for BBB


git clone git://github.com/RobertCNelson/linux-dev.git
cd linux-dev
git checkout origin/am33x-v3.8 -b tmp
./build_kernel.sh

After running ./build_kernel.sh , there will be toolchain installed at linux-dev/dl/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux and also linux kernel binary can be found.


Step 1. For flashing uSD card with Ubuntu 13.04 image, refer to the following link

http://elinux.org/BeagleBoardUbuntu


If you follow the guide in the above link without any error, u can have the uSD burned with bootable image and with it in uSD card slot, you can boot Ubuntu 13.04 on BBB.


Step 2. Now its time to do cross compile SDL.


For this, you need to prepare root file system for BBB before compilation of SDL and you can find the prebuild root file system file in the above file.


Unpack image:

tar xJf ubuntu-13.04-console-armhf-2013-07-22.tar.xz
cd ubuntu-13.04-console-armhf-2013-07-22
sudo tar xfv armhf-rootfs-ubuntu-raring.tar -C ~/rootfs/

Ok. root file system is ready. 


Step 3. Next step is downloading SDL package.

cd ~/rootfs/home/ubuntu
wget http://www.libsdl.org/release/SDL-1.2.15.tar.gz
tar xvfz SDL-1.2.15.tar.gz
cd SDL-1.2.15

For proper compilation and installation, you need to make sure that proper toolchain for BBB (refer to step 0) and inform path to tool chain to Configure script.


Step 4. Configuring and compiling SDL

Below is a script doing configuration and make for my setting. Some modification of this script may be needed to different setting.

Write down a shell script with below content and run it.

Note: Need to replace <user> in the above box with proper name to your system.



Step 5: Installation SDL to target root file system

Now if there is no error after running this script than you can install SDL package to target root file system running below command:


sudo make install


All setup is completed. As like this, you can install other libraries too, for example SDL_image library. 

End.


Next post will be how to make a sample SDL project which will run on target board with help of CMake.




Posted by kevino
,

This is extended from my previous post: http://kevino.tistory.com/entry/CMakeqt5-Simple-example-for-CMake-QT5-package.


The source files in the above link is intended to be built on Host system and run on local machine. Here I will explain how to cross compile the same source codes  with almost same environment.


In order to develop QT app targeted for Arm embedded system, you need to first prepare Qt5 framework suitable for target board.


For i.MX6 Sabre SDB, refer to the following link: https://community.freescale.com/docs/DOC-94066. If you dont see any error in completing procedures described in the above link, you can find many example binaries created in $(TARGET_rootfs)/opt/qt5/examples and verify by running several examples.


Note. You may not see examples compiled even though you followed all steps. In this case, you can compile the examples manually by running below commands on Host system. If compilation is successful, then verify examples by running those on target board.


$ cd $(QTdir)/qtbase

$ make sub-examples


For now, before running cross compile commands, make sure that the following conditions are all met.


1. Target system is booted via nfs and "/" is mounted on ${TARGET_rootfs) of host system.

2. Qt5 for target board is installed at $(TARGET_rootfs)/opt/qt5 and examples at $(TARGET_rootfs)/opt/qt5/examples.

3. Need to verify whether Qt5 works by running example files and checking QT logo moving in 3D screen.

Target> cd /opt/qt5/examples

Target> ./opengl/hellogl_es2/hellogl_es2


If Qt5 is installed, then lets reuse the project source code which will be converted app for target board.


First we need to inform CMake that we will use cross compile and CMake dev team already made this solution since Cmake 2.6 version. 


For this, we can create a new cmake module similar to the below and remember its path.


Toolchain-freescale-imx6q.cmake


Now you can run cmake with crosscompile options to build the source codes. Assuming the above setup,


$ cd /home/<userid>/utils/ltib/rootfs/root

$ 7za x sample1.7z

$ cd sample1

$ mkdir build

$ cd build

$ cmake -DCMAKE_TOOLCHAIN_FILE=$(PATH_to_)/Toolchain-freescale-imx6q.cmake ..

$ make



Note. While running cmake, if you notice an error "Failed to find GLESv2 in "", then you can fix this error by modifying Qt5GuiConfigExtras.cmake at /home/<userid>/utils/ltib/rootfs/opt/qt5/lib/cmake/Qt5Gui/.


At 50 lines

- _qt5gui_find_extra_libs(OPENGL "GLESv2;GLESv2;EGL;GAL" "" "")

+ _qt5gui_find_extra_libs(OPENGL "GLESv2;GLESv2;EGL;GAL" ${CMAKE_FIND_ROOT_PATH}/usr/lib/ "")


I dont think this patch is good but it works for me so you can use this until official patch is ready. At least Qt 5.1.0 has this problem.


You can examine the exe file in target machine whether this Qt5 app can be run. If successful, now you are ready to develop Qt5 application running on Target board.




Posted by kevino
,