-
Notifications
You must be signed in to change notification settings - Fork 75
Cross compiling to ARM
Mátyás Mustoha edited this page Apr 1, 2016
·
6 revisions
This could be a really fast building environment, but it didn't work correctly on my Pi1, and I'm too tired to properly set it up. The steps:
# Install the Jessie rootfs
sudo apt-get install debootstrap
sudo debootstrap --arch amd64 jessie jessie-rootfs
sudo chroot x64-jessie /bin/bash
You are now inside the rootfs. To install the ARM cross compiler:
# Cross tools are in the Emdebian repository
echo "deb http://emdebian.org/tools/debian/ jessie main" >> /etc/apt/sources.list.d/crosstools.list
wget http://emdebian.org/tools/debian/emdebian-toolchain-archive.key
apt-key add emdebian-toolchain-archive.key
# Install
dpkg --add-architecture armhf
apt-get update
apt-get install crossbuild-essential-armhf
Now install the dependencies:
apt-get install git cmake
apt-get install zlib1g-dev:armhf
apt-get install libsdl1.2-dev:armhf libsdl-image1.2-dev:armhf libsdl-mixer1.2-dev:armhf
# apt-get install libsdl2-dev:armhf libsdl2-image-dev:armhf libsdl2-mixer-dev:armhf
And now build SMW:
# Create a new user, you can skip this if you want
useradd -m build -s /bin/bash
passwd build
su - build
# Get the code
git clone --recursive https://github.com/mmatyas/supermariowar.git
cd supermariowar/
mkdir build
cd build/
# Build
CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ \
CFLAGS='-marm -march=armv6' CXXFLAGS='-marm -march=armv6' \
cmake -DDISABLE_DEFAULT_CFLAGS=1 ..
make
For example, here is how to set up a simple build environment for the Raspbery Pi on Ubuntu 14.04:
sudo apt-get install qemu-user-static debootstrap
# Set up a Raspbian rootfs in the 'raspberry' directory
sudo qemu-debootstrap --arch armhf wheezy raspberry http://archive.raspbian.org/raspbian
# Mount some file systems in the rootfs
sudo mount -o bind /dev raspberry/dev
sudo mount -o bind /proc raspberry/proc
sudo mount -o bind /sys raspberry/sys
sudo cp /etc/resolv.conf raspberry/etc/resolv.conf
# Enter
sudo chroot raspberry /bin/bash
Then:
echo "deb http://archive.raspbian.org/raspbian jessie main" >> /etc/apt/sources.list
wget http://archive.raspbian.org/raspbian.public.key -O - | apt-key add -
apt-get update
apt-get install build-essential g++ git \
cmake libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev
Now you can continue with cloning the repository (eg. in /root
) and following the Linux instructions. If your build target needs different build parameters than the default, you can call CMake as cmake .. -DDISABLE_DEFAULT_CFLAGS=1
, and define CFLAGS
and CXXFLAGS
manually.
Please consult your friendly local wizard or sorcerer. The general steps:
- Install or set up the cross compiler for your device (eg.
g++-arm-linux-gnueabihf
) - Check if you have the dependencies
- If your cross compiler package includes SDL, SDL_image, SDL_mixer (or SDL2*) and zlib, you're good to go
- If not, install them on your device or in a rootfs (if your device runs some kind of Linux/Unix), and copy them to your computer
- If this isn't possible, build SDL/SDL2 and zlib yourself, using the cross compiler. You might need to adjust SDL if it doesn't support your device
- Create a CMake toolchain file for the cross compiler
- Run CMake with the toolchain file, then run
make