Skip to content

Cross compilation

Adam Crain edited this page Dec 4, 2017 · 8 revisions

Obtaining the cross compiler

These instructions are for targeting the Moxa UC-8100 with the vendor supplied GCC 4.9 tool-chain.

> wget https://www.moxa.com/drivers/UC/UC-8100/arm-linux-gnueabihf_4.9_Build_amd64_16053113.zip
> unzip arm-linux-gnueabihf_4.9_Build_amd64_16053113.zip
> chmod +x arm-linux-gnueabihf_4.9_Build_amd64_16053113.sh
> sudo ./arm-linux-gnueabihf_4.9_Build_amd64_16053113.sh

Follow the on screen prompt to install the tool-chain to the default location.

Add the cross-compiler toolchain to your path

Add the following line to the bottom of your ~/.bashrc

export PATH=$PATH:/usr/local/arm-linux-gnueabihf-4.9/usr/bin

Cross compiling libsodium and installing it to the tool-chain sysroot

> git clone https://github.com/jedisct1/libsodium.git
> git checkout 1.0.15
> cd libsodium
> ./autogen.sh
> ./configure --host=arm-linux-gnueabihf CFLAGS="--sysroot=/usr/local/arm-linux-gnueabihf-4.9" CXXFLAGS="--sysroot=/usr/local/arm-linux-gnueabihf-4.9" --prefix=/usr/local/arm-linux-gnueabihf-4.9/usr
> make
> sudo make install

Building ssp21-cpp

> mkdir build-arm
> cd build-arm
> cmake .. -DCMAKE_TOOLCHAIN_FILE=../cross/uc8100-gcc-4.9.cmake -DSTATIC_LIBS=ON
> make

This will create executables with all dependencies including libsodium statically linked.

Copy to the UC8100

> scp ssp21-proxy moxa@<ip-address>:~/