Setup CnCpp compile environment for cross compile (armel on amd64) - ReadyNAS/sdk GitHub Wiki
Before you can setup C/C++ compile environment for cross-compile, you must complete setup for compiling amd64 (described in section 1 above).
dev
component from ReadyNAS repository
Add By adding the dev
component, you can get the latest cross-compiler package from our ReadyNAS repository. You need to adjust version number (6.9.1 in below example) based on the currently implemented ReadyNAS OS version. Don't forget to update.
$ sudo sed -i '/^.*readynasos/s/$/ dev/' /chroot/jessie/etc/apt/sources.list.d/readynas.list
$ schroot -c R6 sudo -- apt update
Install key
You must install the NETGEAR key before you can install the cross-compiler.
$ wget http://apt.readynas.com/packages/pub.gpg -O- | schroot -c R6 sudo -- apt-key add -
Install cross-compiler
$ schroot -c R6 sudo -- dpkg --add-architecture amd64
$ schroot -c R6 sudo -- dpkg --add-architecture armel
$ schroot -c R6 sudo -- dpkg --add-architecture armhf
$ schroot -c R6 sudo -- apt update
$ schroot -c R6 sudo -- apt install \
gcc-4.9-arm-linux-gnueabi g++-4.9-arm-linux-gnueabi readynas-build-deps
Generate cross-compiled packages
In this step, create the cross-compiled packages that your application requires. Below is just an example of how to build libc
, libxml2
, and libsqlite3
. Build as needed.
$ schroot -c R6 sudo -- xapt -m -a armel \
libc6-dev libxml2-dev libsqlite3-dev libsystemd-daemon-dev
Cross Compile
If your Makefile is standard, set CC
, CXX
, STRIP
, LIBTOOL
, LDFLAGS
, and PKG_CONFIG_PATH
as below. Please note that the -p
option is used with schroot
to preserve environment variables.
$ CC=arm-linux-gnueabi-gcc-4.9 \
CXX=arm-linux-gnueabi-g++-4.9 \
STRIP=arm-linux-gnueabi-strip \
LIBTOOL=/usr/arm-linux-gnueabi/bin/libtool \
LDFLAGS=-L/usr/arm-linux-gnueabi/lib \
PKG_CONFIG_PATH=/usr/arm-linux-gnueabi/lib/pkgconfig \
ARCH=arm \
schroot -p -c R6 make -- all