13

cross compiling of openssl for linux arm-v5te-linux-gnueabi toolchain. I have the version openssl-0.9.8r I tried

./Configure --prefix=/usr --openssldir=/usr/sbin threads zlib shared no-asm linux-armv4

export CROSS_COMPILE=arm-v5te-linux-gnueabi-

but no avail.

Im in much need of the basic steps to follow to crosscompile it to the openssl binary. I've already tried multiple suggestions across the links, hence in dire need to open a new question.

Please help

Paul Rooney
  • 20,879
  • 9
  • 40
  • 61
buddy
  • 805
  • 1
  • 15
  • 30

3 Answers3

14

This one works:

./Configure linux-generic32 shared  -DL_ENDIAN --prefix=/home --openssldir=/home
make CC=arm-v4t-linux-gnueabi-gcc RANLIB=arm-v4t-linux-gnueabi-ranlib LD=arm-v4t-linux-gnueabi-ld MAKEDEPPROG=arm-v4t-linux-gnueabi-gcc PROCESSOR=ARM
tckmn
  • 57,719
  • 27
  • 114
  • 156
buddy
  • 805
  • 1
  • 15
  • 30
  • 2
    Nice. You should consider upgrading openssl to a newer version so that you can enable ARM optimizations with ./Configure linux-arm. See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=676533 – Christophe Vu-Brugier Apr 03 '13 at 12:36
  • @ChristopheVu-Brugier how can we further use this with application as my question is in link http://stackoverflow.com/questions/24671252/how-to-link-the-openssl-library-with-the-arm-cross-compiler help me to solve this issue – amar Jul 11 '14 at 05:47
  • Use `./Configure --cross-compiler-prefix=arm-v4t-linux-gnueabi- ...` Then make can be used without all the options. – rickfoosusa Oct 09 '18 at 16:55
  • The above comment doesn't work for me - setting CROSS_COMPILE did. – Adam Baxter Feb 23 '19 at 08:13
12

I encountered the same problem and wrote a manual for how to cross compile openssl for arm. I hope this manual can give you some idea:

The process is quite straightforward. In this manual we will give an example for cross compiling OPENSSL for ARM architecture in an Ubuntu Linux System.

  1. Cross compiler

You will need The GNU C/C++ compiler for ARM architecture:

$ sudo apt-get install gcc-4.8-arm-linux-gnueabihf g++-4.8-arm-linux-gnueabihf

  1. openssl source code (version 1.1.1)

The openssl we will build is available at https://github.com/openssl/openssl

$ git clone https://github.com/openssl/openssl.git

  1. Configuration

Navigate into the openssl folder, and execute ./configure as follows:

$ ./Configure linux-armv4 --prefix=/usr/local/openssl/ --openssldir=/usr/local/openssl shared

This configuration sets the target platform linux-armv4 which is the only available ARM platform supported by this openssl. --prefix=/usr/local/openssl tells where to put the installation files. --openssldir=/usr/local/openssl defines the root directory of the openssl installation. shared makes the compiler to generate .so library files. The document INSTALL under folder openssl contains the parameters for ./Configure.

  1. Compilation

$ make CC=arm-linux-gnueabihf-gcc-4.8

CC tells what cross-compiler to use. The default compiler is gcc.

  1. Installation

$ make install

  1. Output

After installation, you will find the following files and folders under /usr/local/openssl

$ ls /usr/local/openssl

bin

ct_log_list.cnf

include

misc

openssl.cnf.dist

share certs

ct_log_list.cnf.dist

lib

openssl.cnf

private

  1. End

make sure the executable binaries are built for ARM:

$ file /usr/local/openssl/bin/openssl

install-arm/bin/openssl: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=a23306c9c8bd553183fc20a37a60dcac8291da91, not stripped

If you see something similar as what is shown above, you have successfully cross-compiled the openssl for the ARM system.

Bing
  • 185
  • 1
  • 4
  • 1
    after configuring with `./Configure linux-armv4 --openssldir=$INSTALL_DIR --cross-compile-prefix=arm-none-eabi-` I tried `make depend` which fails with: `make[1]: Entering directory '/home/AB/Documents/CROSS_COMPILED_SCA/openssl-1.0.2p/crypto' In file included from /usr/include/newlib/dirent.h:6:0, from LPdir_unix.c:32, from o_dir.c:78: /usr/include/newlib/sys/dirent.h:10:2: error: #error " not supported" #error " not supported" ^ Makefile:136: recipe for target 'local_depend' failed make[1]: *** [local_depend] Error 1'` – AjB Nov 21 '19 at 05:17
0
./Configure linux-armv4 --cross-compile-prefix=arm-v5te-linux-gnueabi- --prefix=/usr
make
anton_rh
  • 8,226
  • 7
  • 45
  • 73