how to link the openssl library with the arm-cross compiler

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 04:27:08

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/24671252/how-to-link-the-openssl-library-with-the-arm-cross-compiler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!