1

I have application test.c which by using gcc on host(on ubuntu) machine i have succeed in compilation and successfully ran the application program on host.

now I would like to cross compile the same application with arm-cross compiler for LPC1788. please guide me how to link the openssl library files

My Mkakefile with GCC

CC  = gcc  

 CFLAGS = -D__XMLSEC_FUNCTION__=__FUNCTION__ -DXMLSEC_NO_XKMS=1
-DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -I/usr/include/xmlsec1
-I/usr/include/libxml2 -DXMLSEC_OPENSSL_097=1
-DXMLSEC_CRYPTO_OPENSSL=1 -DXMLSEC_CRYPTO=\"openssl\ -DUNIX_SOCKETS -D XML_SECURITY

 LDFLAGS = -lcrypto -I/usr/include/libxml2 -lxml2 -I/usr/include/xmlsec1 -lxmlsec1    

all:
   $(CC) src/test.c -o test $(CFLAGS) $(LDFLAGS)

by changing the compiler I used the following Makefile

CC = /home/amarayya/doc/tools/arm-2010q1/bin/arm-uclinuxeabi-gcc
CFLAGS = -D__XMLSEC_FUNCTION__=__FUNCTION__ -DXMLSEC_NO_XKMS=1
-DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -I/usr/include/xmlsec1
-I/usr/include/libxml2 -DXMLSEC_OPENSSL_097=1
-DXMLSEC_CRYPTO_OPENSSL=1 -DXMLSEC_CRYPTO=\"openssl\ -DUNIX_SOCKETS -D XML_SECURITY

LDFLAGS = -lcrypto -L/usr/include/libxml2 -lxml2 -L/usr/include/xmlsec1 -lxmlsec1

all:
$(CC) src/test.c -o test $(CFLAGS) $(LDFLAGS)

which leading to these errors

fatal error: openssl/rsa.h: No such file or directory
fatal error: openssl/rsa.h: No such file or directory

what causing these errors and how to over come

Jayesh Bhoi
  • 24,694
  • 15
  • 58
  • 73
amar
  • 509
  • 3
  • 8
  • 17

1 Answers1

0

You cannot use your host libraries when compiling for a different architecture. First, you need to cross compile all non-standard libraries (libxml, libopenssl) for your target machine (i.e. ARM).

Basically, you need to download the source code for these libraries and configure it with

--host=arm-uclinuxeabi --prefix=SOME_HOST_DIR

(or something similar - you might check the README files) assuming, that you have your cross compiler in PATH.

These libraries might also require more libraries to be cross compiled.

When compiling your application you should use these cross compiled libraries.

kayrick
  • 187
  • 4
  • I have cross compiled openssl and copied the these libcrypto.a and libssl.a in the cross compiler path then also resulting in the same errors. – amar Jul 10 '14 at 09:24
  • Do you have the required header file (rsa.h)? Check the installation directory of the cross-compiled opencssl. You would need to point your compiler to this directory - something like -I SOME_HOST_DIR/usr/include – kayrick Jul 10 '14 at 09:34
  • i can find these .h files in path /usr/include/openssl/ – amar Jul 10 '14 at 09:42
  • buy using this link I have compiled openssl http://embeddedcoaching.blogspot.in/2013/10/openssl-cross-compilation-for-arm-on.html – amar Jul 10 '14 at 09:46
  • /usr/include contains host headers, you need to use the cross compiled version. Check the openssl build/installation directory. The link, you provided is a bit confusing - you should not need to use sudo for cross compiling (you don't want to overwrite host libraries with cross compiled versions). – kayrick Jul 10 '14 at 09:51
  • https://stackoverflow.com/questions/11796127/how-to-cross-compile-c-library-with-dependencies This post might help – kayrick Jul 10 '14 at 10:51
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/57087/discussion-between-amar-and-kayrick). – amar Jul 10 '14 at 10:56
  • `--host=arm-uclinuxeabi` - OpenSSL is *not* an autotools project. – jww Jul 10 '14 at 21:00
  • AS i am trying its giving some errors these are due to wrong paths for library,it will be helpful if given details to compile openssl for particular controllers(any arm controller) – amar Jul 11 '14 at 05:12
  • @jww As from the above valuable suggestions i didn’t got the result. it necessary to compile openssl library using cross compiler and with architecture dependencies.? if so any links or docs will be helpful..? how to give path route for it...? is we need to install the cross compiled openssl on host..? how can we give link for the same...? – amar Jul 11 '14 at 05:57