Cross Compile OpenSSL for the Zynq ARM30 Sep 2017
ARM GCC Toolchain
To follow this guide, you obviously need to have an ARM GCC toolchain on your machine.
If you already have Xilinx’s PetaLinux installed, then you can find the toolchain at
Otherwise, you can either:
- Download the ARM GCC toolchain through your package manager; on Ubuntu,
sudo apt-get install gcc-arm-linux-gnueabihf.
- Download a build of the toolchain from Linaro. If you are on Linux, grab the i686 version (non-mingw32). You can find the actual binaries under the
bin/directory after expanding the archive.
First, prepare some directories and clone the OpenSSL repo:
# Create working and installation directories mkdir -p ~/cross-openssl/compiled-openssl && cd ~/cross-openssl # Clone latest version of OpenSSL git clone https://github.com/openssl/openssl.git cd openssl/
Next, define environment variables to simplify the build process. If you installed the ARM GCC toolchain through your package manager, ignore the second variable.
# Installation directory for compiled OpenSSL export INSTALL_DIR=~/cross-openssl/compiled-openssl # Path to ARM cross compiler toolchain binaries export CROSS_DIR=<PATH_TO_TOOLCHAIN>/bin
Now we are ready to configure the OpenSSL build system. For the following steps, please make sure that you are in the main OpenSSL directory; i.e.,
pwd should output
./Configure linux-generic32 shared \ --prefix=$INSTALL_DIR --openssldir=$INSTALL_DIR/openssl \ --cross-compile-prefix=$CROSS_DIR/arm-linux-gnueabihf-
The command above:
- Configures the OpenSSL build for a 32-bit Linux system (linux-generic32)
- Generates both static and dynamic (shared) libraries
- Installs the compiled OpenSSL folder in
- And finally, sets the cross compiler prefix to
Note: if you are using the cross compiler installed through your package manager, replace
Finally, we can build OpenSSL:
make depend make # This takes time! make install
The build process may take some time, depending on your machine. The resulting binary locations are as follows:
Recall that, on Linux, the .a binaries are for static linking, while the .so files are for dynamic linking. The easier approach is to use the former, but your final binary size will be quite large as a result.