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 GIT

Install pre-requisites for the host:

Code: Select all

sudo apt-get install dh-autoreconf libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev
Download GIT 2.22.0 from https://github.com/git/git/releases.

Configuring shared libraries:

This is required because the configure script for git is dumb and apparently doesn't expect you to cross compile.

Run the following commands:

Code: Select all

cd /home/wmt/nas-sysroot/lib
sudo ln -s libpthread.so.0 libpthread.so
sudo ln -s librt.so.1 librt.so
First run:

Code: Select all

make configure
To generate the configure script.

To configure, run:

Code: Select all

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" ./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" ac_cv_fread_reads_directories=yes ac_cv_snprintf_returns_bogus=no
To make, run:

Code: Select all

make -j <num_of_cpu_cores>
Note: The -j option is recommended to speed this up.

NOTE:
-----
This fails at the moment, because git doesn't expect to be cross compiled and tries to link against system libraries. I manually ran the failing linker commands to work around this. I will update this post when/if I find a better way of doing this.

Below are the commands I ran, in order:

Code: Select all

arm-unknown-linux-gnueabi-gcc --sysroot=/home/wmt/nas-sysroot  -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/ -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. -DHAVE_SYSINFO -DGIT_HOST_CPU="\"x86_64\"" -DHAVE_ALLOCA_H -DUSE_CURL_FOR_IMAP_SEND -I/home/wmt/nas-sysroot/usr/local/lib//include -DSHA1_DC -DSHA1DC_NO_STANDARD_INCLUDES -DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 -DSHA1DC_CUSTOM_INCLUDE_SHA1_C="\"cache.h\"" -DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="\"git-compat-util.h\"" -DSHA256_BLK -pthread -DHAVE_PATHS_H -DHAVE_STRINGS_H -DHAVE_DEV_TTY -DHAVE_CLOCK_MONOTONIC -DHAVE_GETDELIM '-DPROCFS_EXECUTABLE_PATH="/proc/self/exe"'  -DFREAD_READS_DIRECTORIES -DNO_STRLCPY -DSHELL_PATH='"/bin/sh"' -DPAGER_ENV='"LESS=FRX LV=-c"' -o git-imap-send -L/home/wmt/nas-sysroot/usr/local/lib -L/home/wmt/nas-sysroot/lib  imap-send.o http.o common-main.o -lcurl  -lssl  -lcrypto libgit.a xdiff/lib.a  -L/home/wmt/nas-sysroot/usr/local/lib//lib -R/home/wmt/nas-sysroot/usr/local/lib//lib -lz -pthread -lrt

Code: Select all

arm-unknown-linux-gnueabi-gcc --sysroot=/home/wmt/nas-sysroot  -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/ -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. -DHAVE_SYSINFO -DGIT_HOST_CPU="\"x86_64\"" -DHAVE_ALLOCA_H -DUSE_CURL_FOR_IMAP_SEND -I/home/wmt/nas-sysroot/usr/local/lib//include -DSHA1_DC -DSHA1DC_NO_STANDARD_INCLUDES -DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 -DSHA1DC_CUSTOM_INCLUDE_SHA1_C="\"cache.h\"" -DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="\"git-compat-util.h\"" -DSHA256_BLK -pthread -DHAVE_PATHS_H -DHAVE_STRINGS_H -DHAVE_DEV_TTY -DHAVE_CLOCK_MONOTONIC -DHAVE_GETDELIM '-DPROCFS_EXECUTABLE_PATH="/proc/self/exe"'  -DFREAD_READS_DIRECTORIES -DNO_STRLCPY -DSHELL_PATH='"/bin/sh"' -DPAGER_ENV='"LESS=FRX LV=-c"' -o git-http-fetch -L/home/wmt/nas-sysroot/usr/local/lib -L/home/wmt/nas-sysroot/lib  http.o http-walker.o http-fetch.o common-main.o -lcurl libgit.a xdiff/lib.a  -L/home/wmt/nas-sysroot/usr/local/lib//lib -R/home/wmt/nas-sysroot/usr/local/lib//lib -lz -pthread -lrt

Code: Select all

arm-unknown-linux-gnueabi-gcc --sysroot=/home/wmt/nas-sysroot  -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/ -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. -DHAVE_SYSINFO -DGIT_HOST_CPU="\"x86_64\"" -DHAVE_ALLOCA_H -DUSE_CURL_FOR_IMAP_SEND -I/home/wmt/nas-sysroot/usr/local/lib//include -DSHA1_DC -DSHA1DC_NO_STANDARD_INCLUDES -DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 -DSHA1DC_CUSTOM_INCLUDE_SHA1_C="\"cache.h\"" -DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="\"git-compat-util.h\"" -DSHA256_BLK -pthread -DHAVE_PATHS_H -DHAVE_STRINGS_H -DHAVE_DEV_TTY -DHAVE_CLOCK_MONOTONIC -DHAVE_GETDELIM '-DPROCFS_EXECUTABLE_PATH="/proc/self/exe"'  -DFREAD_READS_DIRECTORIES -DNO_STRLCPY -DSHELL_PATH='"/bin/sh"' -DPAGER_ENV='"LESS=FRX LV=-c"' -o git-remote-http -L/home/wmt/nas-sysroot/usr/local/lib -L/home/wmt/nas-sysroot/lib  remote-curl.o http.o http-walker.o common-main.o -lcurl  libgit.a xdiff/lib.a  -L/home/wmt/nas-sysroot/usr/local/lib//lib -R/home/wmt/nas-sysroot/usr/local/lib//lib -lz -pthread -lrt
You may need to run these more than once. Afterwards, run "make" again to continue.
-----

The tests do not run when cross-compiling, because they expect GIT to be installed into the system directories.

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
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Setting up phpMyAdmin

phpMyAdmin can't be updated to the latest version, because that doesn't support mysql 5.1, but we can go up to 4.0.10 - newer than what came with the NAS box. First, use the web administration interface to install the official phpMyAdmin add-on (attached). You need to remove the file extension at the end first.

Then, SSH in, and replace the contents of the folder /mnt/HD/HD_a2/Nas_prog/phpMyAdmin, with the contents of the attached tarball.

NOTE: The original phpmyadmin is also here in case it is useful to poke around it later.

NOTES:

The following warnings are visible within phpMyAdmin, but they don't affect its operation:
  • The mysqli extension is missing. Please check your PHP configuration. See our documentation for more information
  • Your PHP parameter session.gc_maxlifetime is lower than cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin.
  • The configuration file now needs a secret passphrase (blowfish_secret).
I will now have a look and see if I can fix/silence these warnings, but rest assured the database is working :)

UPDATE: I have fixed the warnings, new tarball uploaded.
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Compiling NSPR (dependency for NSS)

Download NSPR 4.22 from http://archive.mozilla.org/pub/nspr/releases.

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-mozilla --with-pthreads
To make, run the usual command.

To install, run:

Code: Select all

sudo QEMU_LD_PREFIX=/home/wmt/nas-sysroot make DESTDIR=/home/wmt/nas-sysroot install
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Compiling NSS (required to install SSL certificates) - ABANDONED

Download NSS 3.46 from: http://archive.mozilla.org/pub/security/nss/releases/

Install prerequisites:

Code: Select all

sudo apt install gyp ninja
There is no configure script for this program.

To make, run:

Code: Select all

make CROSS_COMPILE=1 BUILD_OPT=1 NSPR_INCLUDE_DIR=/home/wmt/nas-sysroot/usr/local/include/nspr/ USE_SYSTEM_ZLIB=1 ZLIB_LIBS=-lz 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" DEFAULT_COMPILER="arm-unknown-linux-gnueabi-gcc --sysroot=/home/wmt/nas-sysroot"
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Building libpng (dependency for libGD)

Download libpng 1.6.37 from http://www.libpng.org/pub/png/libpng.html.

Installation procedure

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" CPPFLAGS="-I/home/wmt/nas-sysroot/usr/local/include"
To make, run the usual command.

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 11/09/2019, 15:44, edited 1 time in total.
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Building libjpeg (dependency for libGD)

Download libjpeg v9c from http://ijg.org/.

To configure, run the usual command.

To make, run the usual command.

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
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Building libGD (dependency for Gnuplot)

Download libGD 2.2.5 from https://github.com/libgd/libgd/releases.

Place the attached toolchain file into the Downloads folder.

Installation procedure

Make a build directory and enter it:

Code: Select all

mkdir build && cd build
To configure, run:

Code: Select all

CFLAGS="-I/home/wmt/nas-sysroot/include -I/home/wmt/nas-sysroot/usr/local/include" CXXFLAGS="-I/home/wmt/nas-sysroot/include -I/home/wmt/nas-sysroot/usr/local/include" 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 ../ -DCMAKE_TOOLCHAIN_FILE=../../toolchain.cmake -DCMAKE_C_COMPILER=arm-unknown-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=arm-unknown-linux-gnueabi-g++ -DCMAKE_FIND_ROOT_PATH=/home/wmt/nas-sysroot/ -DENABLE_JPEG=1 -DENABLE_PNG=1
To make, run the usual command.

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
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Compiling libcerf (dependency for Gnuplot)

Download libcerf v1.3 from https://sourceforge.net/projects/libcerf/.

To configure, run the usual command.

To make, run the usual command.

To install, run the usual command.
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Compiling Gnuplot

Download Gnuplot v5.2.7 from https://sourceforge.net/projects/gnuplot/files/gnuplot/.

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" CPPFLAGS="-I/home/wmt/nas-sysroot/usr/local/include" LIBCERF_CFLAGS="-I/home/wmt/nas-sysroot/usr/local/include" LIBCERF_LIBS="-L/home/wmt/nas-sysroot/usr/local/lib" --without-linux-vga --disable-wxwidgets --without-x --without-qt --without-cairo
NOTE: The following commands eventually fail, but this is after the required files have been installed, so it can be safely ignored.

To make, run the usual command.

To install, run:

Code: Select all

sudo QEMU_LD_PREFIX=/home/wmt/nas-sysroot make DESTDIR=/home/wmt/nas-sysroot install
NOTE: This builds support for strings in - the book is a bit out of date, but I have tested that it does indeed work.
Hamish
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

Re: Using the cross compiler

Post by hamishmb »

Installing PIP (Python package manager)

No cross compiling needed, but this seems like the right place to note this.

Follow the instructions at: https://pip.pypa.io/en/stable/installing/
Hamish
Post Reply