1

I want to cross compile a C++ program, which is using some OpenSSL files:

#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/bio.h>
#include <openssl/err.h>

Because the path of the cross compiler (/opt/crosstool/arm-none-linux-gnueabi/include) is different to the default /usr/include path, where all the OpenSSL header files are, I had to set the include path with right click on project -> properties -> C/C++ General -> Path and Symbols --> Add... -> /usr/include to include the header files.

Same with the libcrypto.so :

...C/C++ General --> Libraries --> Add... crypto

...C/C++ General --> Library Paths --> Add... /usr/lib/i386-linux-gnu (in this folder I found the librypto.so)

When building my project I get following error:

/opt/crosstool/arm-none-linux-gnueabi/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: skipping incompatible /usr/lib/i386-linux-gnu/libcrypto.so when searching for -lcrypto
    /opt/crosstool/arm-none-linux-gnueabi/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: skipping incompatible /usr/lib/i386-linux-gnu/libcrypto.a when searching for -lcrypto
    /opt/crosstool/arm-none-linux-gnueabi/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lcrypto

Seems to be a linking error, but I don´t know why. Thanks for help.

Snowman
  • 139
  • 3
  • 15
  • Which version of OpenSSL are you using? Where is this come from: `/opt/crosstool/arm-none-linux-gnueabi`? (Its OK, I'm trying to set-up a test rig to test an answer). – jww Mar 30 '16 at 14:22
  • I´m using version 1.0.1. The path is the path to my cross compiler, it was the default path after installing my cross compiler. In this path I have all the folders needed for my embedded hardware, some extra libraries for the hardware and also default libraries (and header files), but not the OpenSSL libraries. I tried to copy the libcrypto.so files into the folders of the cross compiler, but still the same error. – Snowman Mar 31 '16 at 06:19

1 Answers1

1

Okay, finally solved the problem. I didn´t know that I had to configure OpenSSL for using it to cross compile with ARM.

Just start your terminal and type:

    export cross=arm-none-linux-gnueabi-
    cd openssl-1.0.1s
    ./Configure dist --prefix=$HOME/opensslArm
    make CC="${cross}gcc" AR="${cross}ar r" RANLIB="${cross}ranlib"
    make install

Now you have a folder called opensslArm in your home directory. In this folder you will find all the header files and the library itself. So in Eclipse add the path to the opensslArm/include to your includes and opensslArm/lib to your Library paths. Look here for further information: Cross Compile OpenSSH for ARM

Community
  • 1
  • 1
Snowman
  • 139
  • 3
  • 15