9
votes

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!

4
Did you find solution? I too bumped this problem. I hope you found the answer as it is 9 months old. If you find the solution then answer it.Necktwi
Same problem compiling under a container (Linux 4.13.13-6-pve #1 SMP PVE 4.13.13-42 (Fri, 9 Mar 2018 11:55:18 +0100) x86_64 GNU/Linux).Sandburg

4 Answers

14
votes

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.

1
votes

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
0
votes

Libraries once built for a particular platform will be for a particular platform and can only be used on other platform only if its binary is compatible.

For cross-compilation, you may required binaries for different platforms too.

Regarding this error, it seems that you have not mentioned include path for OpenSSL header files.

Without libraries, you will get linker error, not compiler error.

In this case, compiler is somehow is not able to locate the header files. So, make sure that include path is provided.

0
votes
sudo apt install libssl-dev   

this also works for some oddball linux distros.