GithubHelp home page GithubHelp logo

codetronik / openssl-curl-android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from robertying/openssl-curl-android

0.0 0.0 1.0 39 KB

Compile openssl and curl for Android

License: MIT License

Shell 100.00%

openssl-curl-android's Introduction

openssl-curl-android

Compile openssl and curl for Android

Prerequisites

Make sure you have Android NDK installed.

You may also need to install autoconf and libtool toolchains as well as build essentials.

Download

If you do not want to compile them yourself, you can download pre-compiled static libraries from releases. They are in build.tar.gz.

Doing your own compilation is recommended, since the pre-compiled binary can become outdated soon.

Checkout newer versions in git submodules to compile newer versions of the libraries. For example, to build OpenSSL_1_1_1l and curl-7_78_0:

cd openssl
git fetch
git checkout OpenSSL_1_1_1l
cd ..

cd curl
git fetch
git checkout curl-7_78_0
cd ..

Usage

git clone https://github.com/robertying/openssl-curl-android.git
cd openssl-curl-android
git submodule update --init --recursive

export NDK=your_android_ndk_root_here # e.g. $HOME/Library/Android/sdk/ndk/23.0.7599858
export HOST_TAG=see_this_table_for_info # e.g. darwin-x86_64, see https://developer.android.com/ndk/guides/other_build_systems#overview
export MIN_SDK_VERSION=23 # or any version you want

chmod +x ./build.sh
./build.sh

All compiled libs are located in build/openssl and build/curl directory.

Use NDK to link those libs, part of Android.mk example:

include $(CLEAR_VARS)
LOCAL_MODULE := curl
LOCAL_SRC_FILES := build/curl/$(TARGET_ARCH_ABI)/libcurl.a
include $(PREBUILT_STATIC_LIBRARY)

Options

  • Change scripts' configure arguments to meet your own needs.

  • For now, using TLS (https) in Android would throw peer verification failed.

    Please explicitly set curl_easy_setopt(curl, CURLOPT_CAINFO, CA_BUNDLE_PATH); where CA_BUNDLE_PATH is your ca bundle path in the device storage.

    You can download and copy cacert.pem to Android assets or the device internal storage to get TLS working for libcurl.

Working Examples

  • See this minimal example which calls curl from Android app, using JNI to use libcurl: AndroidCurlExample. It includes Android.mk setup and JNI configurations.

  • Checkout this more complex repo to see how to integrate other compiled static libraries into an existing Android project, including Android.mk setup and JNI configurations.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.