Installing/cross compiling programs

Holds topics that document the NAS box's features and any related procedures. Stuff in here should eventually make it into a specification or the user guide.
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Compiling wget

Download wget 1.20.3 from https://ftp.gnu.org/gnu/wget/.

To configure, wget needs to be told when the OpenSSL libraries and headers are. We have also specified to use OpenSSL and not to use libpsl or zlib:

Code: Select all

./configure --host=arm-unknown-linux-gnueabi --target=arm-unknown-linux-gnueabi --build=x86_64-linux-gnu CC="arm-unknown-linux-gnueabi-gcc --sysroot=/home/wmt/nas-sysroot" CXX="arm-unknown-linux-gnueabi-g++ --sysroot=/home/wmt/nas-sysroot" LD="arm-unknown-linux-gnueabi-ld --sysroot=/home/wmt/nas-sysroot" --with-ssl=openssl --with-libssl-prefix=/home/wmt/nas-sysroot/usr/local/ --without-libpsl --without-zlib
To make, run the usual command.

To test, run "make check". These tests also seem to fail, but wget works fine.

To install, run the usual command.
Last edited by hamishmb on 19/07/2019, 12:47, edited 3 times in total.
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Compiling which

Download which from https://www.gnu.org/software/which

To configure, run the usual command.

To make, run the usual command.

To install, run the usual command.
Last edited by hamishmb on 19/07/2019, 12:47, edited 3 times in total.
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Compiling bison (dependency for PHP)

Download bison 3.4 from http://ftp.gnu.org/gnu/bison/.

To configure, run the usual command.

To make, run the usual command.

To test, run "make check"

To install, run:

Code: Select all

sudo PATH="/home/wmt/x-tools/arm-unknown-linux-gnueabi/bin:$PATH" make DESTDIR=/home/wmt/nas-sysroot install
Last edited by hamishmb on 19/07/2019, 12:47, edited 3 times in total.
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Compiling libxml2 (dependency for PHP)

Download libxml2 2.9.9 from http://xmlsoft.org/.

To configure, we can disable Python support, because we don't need it:

Code: Select all

./configure --host=arm-unknown-linux-gnueabi --target=arm-unknown-linux-gnueabi --build=x86_64-linux-gnu CC="arm-unknown-linux-gnueabi-gcc --sysroot=/home/wmt/nas-sysroot" CXX="arm-unknown-linux-gnueabi-g++ --sysroot=/home/wmt/nas-sysroot" LD="arm-unknown-linux-gnueabi-ld --sysroot=/home/wmt/nas-sysroot" --without-python
Make with:

Code: Select all

make -j <num_of_cpu_cores>
It is recommended to use the -j option as this compilation takes some time.

To test, run "make check". This eventually segfaults, but this is probably due to QEMU.

To install:

Code: Select all

sudo PATH="/home/wmt/x-tools/arm-unknown-linux-gnueabi/bin:$PATH" make DESTDIR=/home/wmt/nas-sysroot install
Last edited by hamishmb on 19/07/2019, 12:48, edited 3 times in total.
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Compiling re2c (dependency for PHP)

Download re2c 1.1.1 from http://re2c.org/.

To configure, use the usual command.

To make, run:

Code: Select all

make -j <num_of_cpu_cores>
The -j option is recommended here because this build takes a while.

To test, run "make check".

To install, run the usual command.
Last edited by hamishmb on 19/07/2019, 12:48, edited 3 times in total.
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Compiling PHP

First install the prerequisite re2c on the host:

Code: Select all

sudo apt install re2c
Download PHP 7.3.6 from https://www.php.net

Then configure:

Code: Select all

./configure --prefix=/home/wmt/nas-sysroot/usr/local/ --host=arm-unknown-linux-gnueabi --target=arm-unknown-linux-gnueabi --build=x86_64-linux-gnu CC="arm-unknown-linux-gnueabi-gcc --sysroot=/home/wmt/nas-sysroot -std=gnu99" CXX="arm-unknown-linux-gnueabi-g++ --sysroot=/home/wmt/nas-sysroot" LD="arm-unknown-linux-gnueabi-ld --sysroot=/home/wmt/nas-sysroot" CFLAGS="-I/home/wmt/nas-sysroot/usr/local/include" CPPFLAGS="-I/home/wmt/nas-sysroot/usr/local/include" LIBS="-lrt" --with-libxml-dir=/home/wmt/nas-sysroot/usr/local/include/libxml --with-zlib-dir=/home/wmt/nas-sysroot/usr/local/ --with-openssl-dir=/home/wmt/nas-sysroot/usr/local/include/ --without-iconv --disable-phar --without-pear
I had to disable a few features to make this work. Hopefully it doesn't matter.

To make, run:

Code: Select all

make -j <num_of_cpu_cores>
The -j option is recommended because this takes a while to build.

To test, run "make test"

To install, run the usual command.

TODO note about weird binary names.
Last edited by hamishmb on 19/07/2019, 12:48, edited 7 times in total.
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Compiling libaio (dependency for MariaDB)

This one is different and requires only one command:

Code: Select all

sudo make prefix="/home/wmt/nas-sysroot/usr/local" install
Last edited by hamishmb on 19/07/2019, 12:48, edited 2 times in total.
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Compiling cmake 3.2.2 for host (dependency for MariaDB)

Cmake 2.8 seems too old to cut it for this more complex cross compilation, so following the instructions here https://lists.launchpad.net/maria-discuss/msg02911.html, we will build cmake 3.2.2 instead.

Download cmake 3.2.2 from https://github.com/Kitware/CMake/releas ... v3.3.0-rc3.

To configure, run:

Code: Select all

./bootstrap
To make, run the usual command. NOTE: The -j option is recommended to speed this build up.

To test, run "make test".

To install, run:

Code: Select all

sudo make install
NOTE:

In order to use cmake 3.2.2, instead of the system 2.8, you may need to run:

Code: Select all

export CMAKE_ROOT=/usr/local/share/cmake-3.2/
and

Code: Select all

. ~/.bashrc
Last edited by hamishmb on 19/07/2019, 12:48, edited 4 times in total.
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Building MariaDB (ABANDONED)

NOTE: While this is abandoned, I have kept the toolchain file here, in case we need to build something else with cmake.

Download MariaDB 10.3.16 from downloads.mariadb.org.

Install the prerequisites:

Code: Select all

sudo apt install cmake libevent-dev git libssl-dev
MariaDB uses the cmake system. In order to cross compile with cmake, a toolchain file needs to be created. You can download this as an attachment.

Build helper tools

You need to make a build directory for these tools. Make the build directory outside the source directory!

Code: Select all

mkdir -p mariadb/native
cd mariadb/native
These need to be built first, and for the host architecture. Create them with the following commands:

Code: Select all

cmake ../../mariadb-10.3.16 -DWITH_SSL=system
make import_executables -j <num_of_cpu_cores>
cd ..
Build MariaDB for target

You need another temporary directory for this, outside the MariaDB source directory, as before:

Code: Select all

mkdir cross
cd cross
Run these commands to configure the build:

Code: Select all

CFLAGS="-I/home/wmt/nas-sysroot/include -I/home/wmt/nas-sysroot/usr/local/include -I/home/wmt/nas-sysroot/usr/local/include/ncurses" CXXFLAGS="-I/home/wmt/nas-sysroot/include -I/home/wmt/nas-sysroot/usr/local/include -I/home/wmt/nas-sysroot/usr/local/include/ncurses" LDFLAGS="-L/home/wmt/nas-sysroot/lib -L/home/wmt/nas-sysroot/usr/local/lib" CXXLDFLAGS="-L/home/wmt/nas-sysroot/lib -L/home/wmt/nas-sysroot/usr/local/lib" cmake ../../mariadb-10.3.16 -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake -DCMAKE_C_COMPILER=arm-unknown-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=arm-unknown-linux-gnueabi-g++ -DIMPORT_EXECUTABLES=/home/wmt/Downloads/mariadb/native/import_executables.cmake -DCMAKE_FIND_ROOT_PATH=/home/wmt/nas-sysroot/
To make, run:
  • make -j <num_of_cpu_cores>
The -j option is recommended, because this is slow to compile.

To install, run:

Code: Select all

sudo PATH="/home/wmt/x-tools/arm-unknown-linux-gnueabi/bin:$PATH" make DESTDIR=/home/wmt/nas-sysroot install
NOTE: Currently fails to execute: A newer kernel is required to run this binary.
Attachments
toolchain.cmake.txt
(327 Bytes) Downloaded 93 times
Last edited by hamishmb on 02/07/2019, 22:01, edited 4 times in total.
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Compiling curl (dependency for Git)

Download curl 7.65.1 from https://curl.haxx.se/download.html.

To configure, run:

Code: Select all

./configure --host=arm-unknown-linux-gnueabi --target=arm-unknown-linux-gnueabi --build=x86_64-linux-gnu CC="arm-unknown-linux-gnueabi-gcc --sysroot=/home/wmt/nas-sysroot" CXX="arm-unknown-linux-gnueabi-g++ --sysroot=/home/wmt/nas-sysroot" LD="arm-unknown-linux-gnueabi-ld --sysroot=/home/wmt/nas-sysroot" --with-ssl --with-zlib CFLAGS="-I/home/wmt/nas-sysroot/usr/local/include -I/home/wmt/nas-sysroot/usr/local/include/openssl -I/home/wmt/nas-sysroot/usr/local/include/ncurses" CPPFLAGS="-I/home/wmt/nas-sysroot/usr/local/include -I/home/wmt/nas-sysroot/usr/local/include/openssl -I/home/wmt/nas-sysroot/usr/local/include/ncurses -I/home/wmt/nas-sysroot/usr/local/lib/libffi-3.2.1/include/" LDFLAGS="-L/home/wmt/nas-sysroot/usr/local/lib"
To make, run:

Code: Select all

make -j <num_of_cpu_cores>
The -j option is recommended here to speed things up.

The tests will not run for this program when it is being cross-compiled.

To install, run:

Code: Select all

sudo PATH="/home/wmt/x-tools/arm-unknown-linux-gnueabi/bin:$PATH" make DESTDIR=/home/wmt/nas-sysroot install
Last edited by hamishmb on 19/07/2019, 12:49, edited 3 times in total.
Hamish
Post Reply