Cross-compiling libcurl Dynamic Library for ARM

Introduction

Recently, due to project requirements, I needed to cross-compile libcurl to enable HTTPS communication. Here I’ll document the process.

First, download the latest version of the source code and extract it:

image.png

I used the cross-compilation toolchain that comes with Deepin Linux. Just install it with sudo apt install gcc-5-arm-linux-gnueabihf.

arm-linux contents:

image.png

In the openssl directory, run the following commands:

source ../arm-linux
./Configure --prefix=$(pwd)/../output shared no-asm linux-armv4
make -j4
make install

First, import the environment variables, then compile with the output path set to the “output” directory.

Then in the libcurl directory, run the following commands:

source ../arm-linux
./configure --with-ssl=$(pwd)/../output --prefix=$PWD/../output --build=x86_64-pc-linux-gnu --host=arm-linux-gnueabihf  CC=arm-linux-gnueabihf-gcc-5 --without-zlib

Here’s a summary of the curl configuration:

  curl version:     7.58.0
  Host setup:       x86_64-pc-linux-gnu
  Install prefix:   /media/linan/72605383-b1ba-4c79-90fd-443514396fbc/curl_workdir/curl-7.58.0/output
  Compiler:         arm-linux-gnueabihf-gcc-5
  SSL support:      enabled (OpenSSL)
  SSH support:      no      (--with-libssh2)
  zlib support:     no      (--with-zlib)
  brotli support:   no      (--with-brotli)
  GSS-API support:  no      (--with-gssapi)
  TLS-SRP support:  enabled
  resolver:         POSIX threaded
  IPv6 support:     enabled
  Unix sockets support: enabled
  IDN support:      no      (--with-{libidn2,winidn})
  Build libcurl:    Shared=yes, Static=yes
  Built-in manual:  enabled
  --libcurl option: enabled (--disable-libcurl-option)
  Verbose errors:   enabled (--disable-verbose)
  SSPI support:     no      (--enable-sspi)
  ca cert bundle:   no
  ca cert path:     no
  ca fallback:      no
  LDAP support:     no      (--enable-ldap / --with-ldap-lib / --with-lber-lib)
  LDAPS support:    no      (--enable-ldaps)
  RTSP support:     enabled
  RTMP support:     no      (--with-librtmp)
  metalink support: no      (--with-libmetalink)
  PSL support:      no      (libpsl not found)
  HTTP2 support:    disabled (--with-nghttp2)
  Protocols:        DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP

Then run make and make install. An “output” directory will appear in the curl directory.

Finally, what we need are the dynamic libraries from openssl and curl: libssl.so, libcrypto.so, and libcurl.so.

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy