Cross compiling "OpenSSL" Error

13,348

Solution 1

I know this question is a little old, but since I came to it with the same problem, I'm going to leave this here for future reference.

The solution I found was to manually compile OpenSSL with the installed cross-compiler and then manually install it to the cross-compilation libraries folder.

First, I installed the cross-compiler (I'm using Ubuntu 14.04). I installed both the C compiler and the C++ compiler. I also installed two cross-compiler toolchains, one with hard-floating point support (arm-linux-gnueabihf) and one without (arm-linux-gnueabi). Two directories are created (as noted on the question) /usr/arm-linux-gnueabi and /usr/arm-linux-gnueabihf, where the cross-compiled libraries should be installed to.

sudo apt-get install {gcc,g++}-arm-linux-gnueabi{,hf}

Secondly, cloned the OpenSSL Git repository and checked out the version I was interested in (1.0.2):

git clone https://github.com/openssl/openssl
git checkout OpenSSL_1_0_2       # or another version

Then, I configured the environment for cross-compilation and changed the installation directory (the prefix), and built the library following the instructions provided in the INSTALL file (and by forcing to use the specific cross-compilation toolchain):

export CROSS=arm-linux-gnueabi # or arm-linux-gnueabihf
export AR=${CROSS}-ar
export AS=${CROSS}-as
export CC=${CROSS}-gcc
export CXX=${CROSS}-g++
export LD=${CROSS}-ld

./Configure --prefix=/usr/${CROSS} os/compiler:${CC}
make
sudo make install

You can repeat the process and compile with both toolchains (arm-linux-gnueabi and arm-linux-gnueabihf).

Hope this helps.

Solution 2

In my case, exactly the same error message (but I was compiling in 32 bits on a 64 bits machine). I solved this with installing another architecture:

apt-get install libssl-dev:i386
Share:
13,348
user2984715
Author by

user2984715

Updated on June 04, 2022

Comments

  • user2984715
    user2984715 about 2 years

    I'm using the include: < openssl/md5.h > in my c code. When I compile it with "gcc" compiler I don't have any errors, but when I compile it with cross compiler "arm-linux-gnueabi-gcc" I have the following error:

    /usr/include/openssl/e_os2.h:56:33: fatal error: openssl/opensslconf.h: No such file or directory 
    compilation terminated.
    

    I think that this error is because I don't have the openssl libraries in the cross compiler folder "/usr/arm-linux-gnueabi-gcc".

    Can anyone say me if is this the cause of the error? And how I can install the openssl libraries for cross compiler?

    I'm starting in cross-compiling, and I don't have much knowledge about this. Thanks for your time!

  • user2984715
    user2984715 over 10 years
    I have mentioned the include in my c code. The include path that I have write is the following:'#include <openssl/md5.h>'. I think that I have to compile the openssl libraries to the cross compile? But how I can do it?
  • h0ru5
    h0ru5 over 9 years
    You should consider using a chroot for this, as it will overwrite your system's openssl
  • Janito Vaqueiro Ferreira Filho
    Janito Vaqueiro Ferreira Filho over 9 years
    Won't setting the prefix be enough?
  • h0ru5
    h0ru5 over 9 years
    have not tried it, but could be enough since configure should know where to install
  • kaushal
    kaushal almost 8 years
    This saved my day or should I say week. I had the exact issue where I needed to compile for an ARM and gcc linaro toolchain by default doesn't have the openssl lib.
  • Admin
    Admin about 7 years
    I think is a miss comentary