Snowman
Snowman

Reputation: 179

Eclipse CDT - Link libcrypto.so for cross compiling

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.

Upvotes: 1

Views: 1144

Answers (1)

Snowman
Snowman

Reputation: 179

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

Upvotes: 1

Related Questions