Giter VIP home page Giter VIP logo

openssl_for_ios_and_android's Introduction

More iOS and Android build scripts

simple-build-ios-and-android-script

OpenSSL & cURL Library for iOS and Android

libraryversionplatform supportarch supportpull commit
openssl1.1.1diosarmv7 arm64 arm64e x86_64 aae1672
1.1.1tandroidarmeabi-v7a arm64-v8a x86 x86_64 aae1672
nghttp21.40.0iosarmv7 arm64 arm64e x86x86_64 aae1672
androidarmeabi-v7a arm64-v8a x86 x86_64 aae1672
curl7.68.0iosarmv7 arm64 arm64e x86_64 aae1672
androidarmeabi-v7a arm64-v8a x86 x86_64 aae1672

Downloads

If you do not want to build it by yourself, you could download our prebuilt library from there

OpenSSL Version

nghttp2 Version

cURL Version

Android NDK Version

How to build

!!!Scripts are compiled and passed on the Mac, not tested on the Linux system

  • MacOS info: 10.15.2

For iOS

  • Xcode info: Version 11.3.1 (11C504) (for reference only)
  • Build dependencies: todo
  • Build order: 1.build openssl, 2.build nghttp2, 3.build curl (curl depend openssl and nghttp2)
  • only build static library(.a)
  • build sh cmd: for example:
$ cd tools
$ sh build-ios-openssl.sh
$ sh build-ios-nghttp2.sh
$ sh build-ios-curl.sh

For Android

  • Android Studio info: 4.1, November 5, 2020 (for reference only)
  • Android NDK info: r21d
  • Build dependencies: todo
  • Build order: 1.build openssl, 2.build nghttp2, 3.build curl (curl depend openssl and nghttp2)
  • build static library(.a) and dynamic library (exclude curl arm64-v8a)
  • env macro: for example:
export ANDROID_NDK_ROOT=/Location/where/installed/android-ndk-r21d

  • build sh cmd: for example:
$ cd tools
$ export api=16
$ ./build-android-openssl.sh arm
$ ./build-android-nghttp2.sh arm
$ ./build-android-curl.sh arm
$ export api=21
$ ./build-android-openssl.sh arm64
$ ./build-android-nghttp2.sh arm64
$ ./build-android-curl.sh arm64

You must build openssl and nghttp2(support http2) first

Others

OpenSSL for Android is build with libz support using dynamic link. libz is publically provided by Android system.

Demo

iOS

  • Xcode version 11.3.1
  • The latest available example is in the demo2 folder (/openssl_for_ios_and_android/example/ios/demo2).
  • Copy libcrypto-universal.a, libcurl-universal.a, libnghttp2-universal.a, libssl-universal.a four files to folder (/openssl_for_ios_and_android/example/ios/demo2/test_curl_with_ssl_and_http2_ios/test/lib)
  • Use Xcode open project test.

Android

  • Android Studio 3.5.3
  • The latest available example is in the demo2 folder (/openssl_for_ios_and_android/example/android/demo2).
  • Copy libcrypto.a, libcurl.a, libnghttp2.a, libssl.a four files to folder (/openssl_for_ios_and_android/example/android/demo2/test_curl_with_ssl_and_http2_android/app/src/main/cpp/test/lib) (armeabi-v7a, arm64-v8a, x86_64)
  • Use Android Studio open project test.

How to use

For iOS

Copy lib/libcrypto.a and lib/libssl.a and lib/libcurl.a to your project.

Copy include/openssl folder and include/curl folder to your project.

Add libcrypto.a and libssl.a and libcurl.a to Frameworks group and add them to [Build Phases] ====> [Link Binary With Libraries].

Add openssl include path and curl include path to your [Build Settings] ====> [User Header Search Paths]

About "__curl_rule_01__ declared as an array with a negative size" problem

When you build cURL for arm64 you will get this error.

You need to change curlbuild.h from :

#define CURL_SIZEOF_LONG 4

to :

#ifdef __LP64__
#define CURL_SIZEOF_LONG 8
#else
#define CURL_SIZEOF_LONG 4
#endif

For Android

Copy lib/armeabi folder and lib/armeabi-v7a folder and lib/x86 to your android project libs folder.

Copy include/openssl folder and include/curl to your android project.

Android Makefile

Add openssl include path to jni/Android.mk.

#Android.mk

include $(CLEAR_VARS)

LOCAL_MODULE := curl
LOCAL_SRC_FILES := Your cURL Library Path/$(TARGET_ARCH_ABI)/libcurl.a
include $(PREBUILT_STATIC_LIBRARY)


LOCAL_C_INCLUDES := \
	$(LOCAL_PATH)/Your Openssl Include Path/openssl \
	$(LOCAL_PATH)/Your cURL Include Path/curl

LOCAL_STATIC_LIBRARIES := libcurl

LOCAL_LDLIBS := -lz
	

CMake

Define ssl, crypto, curl as STATIC IMPORTED libraries.

add_library(crypto STATIC IMPORTED)
set_target_properties(crypto
  PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libcrypto.a)

add_library(ssl STATIC IMPORTED)
set_target_properties(ssl
  PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libssl.a)

add_library(curl STATIC IMPORTED)
set_target_properties(curl
  PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libcurl.a)

Then link these libraries with your target, e.g.

target_link_libraries( # Specifies the target library.
                       native-lib

                       curl
                       ssl
                       crypto
                       )

About "libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'signal' " problem

when you get these error

libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'signal' 

libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr' 

You need to rebuild OpenSSL static library with NDK API level 16 or earlier

If you build OpenSSL with API level 16 or earlier you may not build it for arch 64 bit only support 32 bit

more information :

openssl/openssl#988

http://stackoverflow.com/questions/37122126/whats-the-exact-significance-of-android-ndk-platform-version-compared-to-api-le

openssl_for_ios_and_android's People

Contributors

arakawa96 avatar asteriskzuo avatar cinakyn avatar davidshen84 avatar dourgulf avatar leenjewel avatar leso-kn avatar lizhangqu avatar nguoithichkhampha avatar xbolshe avatar zzhangxiaoyun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openssl_for_ios_and_android's Issues

Reporting a vulnerability

Hello!

I hope you are doing well!

We are a security research team. Our tool automatically detected a vulnerability in this repository. We want to disclose it responsibly. GitHub has a feature called Private vulnerability reporting, which enables security research to privately disclose a vulnerability. Unfortunately, it is not enabled for this repository.

Can you enable it, so that we can report it?

Thanks in advance!

PS: you can read about how to enable private vulnerability reporting here: https://docs.github.com/en/code-security/security-advisories/repository-security-advisories/configuring-private-vulnerability-reporting-for-a-repository

PKG_CONFIG_PATH

我下载master分支,进入tools文件夹执行下面的脚本后一直报PKG_CONFIG_PATH not defined 请问我应该追加什么配置。
/build-android-openssl.sh arm64
PKG_CONFIG_PATH not defined

[BUG] doesnt run on ubuntu 16.04

Was it suposed to run fine on linux?

rafa@ubuntu:~/Desktop/m3/openssl_for_ios_and_android-master/tools$ sh ./build-openssl4android.sh 
./build-openssl4android.sh: 19: ./build-openssl4android.sh: source: not found
./build-openssl4android.sh: 23: ./build-openssl4android.sh: TOOLS_ROOT: parameter not set
rafa@ubuntu:~/Desktop/m3/openssl_for_ios_and_android-master/tools$ 

Ubuntu 15.04下报错

Configured for linux64-mips64.
./build-openssl4android.sh: 行 56: /home/public/user/openssl/tools/armeabi-android-toolchain/bin/make: cannot execute binary file: 可执行文件格式错误
感觉快要成功了。。。希望能帮下忙,谢谢

whats lacking

export ANDROID_NDK_ROOT=/User/tormentous/android-ndk-r23

cd tools
export api=16
./build-android-openssl.sh arm
./build-android-nghttp2.sh arm
./build-android-curl.sh arm

pwd_path=/Users/tormentous/Downloads/openssl_for_ios_and_android-master/tools
TOOLS_ROOT=/Users/tormentous/Downloads/openssl_for_ios_and_android-master/tools
https://www.openssl.org/source/openssl-1.1.1i.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 9578k 100 9578k 0 0 179k 0 0:00:53 0:00:53 --:--:-- 175k
PATH=/Users/tormentous/android-ndk-r23/toolchains/llvm/prebuilt/darwin-x86_64/bin:/Users/tormentous/.sdkman/candidates/kotlin/current/bin:/Users/tormentous/.sdkman/candidates/java/current/bin:/usr/local/opt/bison/bin:/usr/local/opt/bison/bin:/opt/local/bin:/opt/local/sbin:/Users/tormentous/google-cloud-sdk/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/dzebb/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/:/Users/tormentous/Library/Android/sdk/platform-tools/:/usr/local/go/bin
Android openssl-1.1.1i start...
configure armeabi-v7a start...
~/Downloads/openssl_for_ios_and_android-master/tools ~/Downloads/openssl_for_ios_and_android-master/tools
ANDROID_NDK_HOME=/Users/tormentous/android-ndk-r23
arch = arm
abi = armeabi-v7a
abi_triple = arm-linux-android
PLATFORM_TYPE = Android
ANDROID_API = 16
in_dir = /Users/tormentous/Downloads/openssl_for_ios_and_android-master/tools/../output/android/openssl-armeabi-v7a
out_dir = /Users/tormentous/Downloads/openssl_for_ios_and_android-master/tools/../output/android/openssl-armeabi-v7a
AR = arm-linux-androideabi-ar
CC = armv7a-linux-androideabi16-clang
CXX = armv7a-linux-androideabi16-clang++
AS = arm-linux-androideabi-as
LD = arm-linux-androideabi-ld
RANLIB = arm-linux-androideabi-ranlib
STRIP = arm-linux-androideabi-strip
CFLAGS = -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wno-unused-function -fno-integrated-as -fstrict-aliasing -fPIC -DANDROID -D__ANDROID_API__=16 -Os -ffunction-sections -fdata-sections -I/Users/tormentous/android-ndk-r23/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include -I/Users/tormentous/android-ndk-r23/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/local/include
CXXFLAGS = -std=c++14 -Os -ffunction-sections -fdata-sections
LDFLAGS = -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wl,--fix-cortex-a8 -Wl,--gc-sections -Os -ffunction-sections -fdata-sections -L/Users/tormentous/android-ndk-r23/toolchains/llvm/prebuilt/darwin-x86_64/arm-linux-androideabi/lib -L/Users/tormentous/android-ndk-r23/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/arm-linux-androideabi/16 -L/Users/tormentous/android-ndk-r23/toolchains/llvm/prebuilt/darwin-x86_64/lib
CPPFLAGS = -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wno-unused-function -fno-integrated-as -fstrict-aliasing -fPIC -DANDROID -D__ANDROID_API__=16 -Os -ffunction-sections -fdata-sections -I/Users/tormentous/android-ndk-r23/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include -I/Users/tormentous/android-ndk-r23/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/local/include
Configuring OpenSSL version 1.1.1i (0x1010109fL) for android-arm
Using os-specific seed configuration
$ANDROID_NDK_HOME=/Users/tormentous/android-ndk-r23 is invalid at (eval 10) line 37.
make armeabi-v7a start...
make: *** No rule to make target `clean'. Stop.

ndk r19c编译的openssl无法让libcurl支持armeabi架构

use ANDROID_API=15
use NDK=/Users/panchen/Documents/souce/android-ndk/android-ndk-r16b
export ARCH=android
export NDK_TOOLCHAIN_BASENAME=/Users/panchen/Documents/test/test/openssl_for_ios_and_android-master/tools/armeabi-android-toolchain/bin/arm-linux-androideabi
export SYSROOT=/Users/panchen/Documents/test/test/openssl_for_ios_and_android-master/tools/armeabi-android-toolchain/sysroot
export CC=/Users/panchen/Documents/test/test/openssl_for_ios_and_android-master/tools/armeabi-android-toolchain/bin/arm-linux-androideabi-clang
export CXX=/Users/panchen/Documents/test/test/openssl_for_ios_and_android-master/tools/armeabi-android-toolchain/bin/arm-linux-androideabi-clang++
export LINK=/Users/panchen/Documents/test/test/openssl_for_ios_and_android-master/tools/armeabi-android-toolchain/bin/arm-linux-androideabi-clang++
export LD=/Users/panchen/Documents/test/test/openssl_for_ios_and_android-master/tools/armeabi-android-toolchain/bin/arm-linux-androideabi-ld
export AR=/Users/panchen/Documents/test/test/openssl_for_ios_and_android-master/tools/armeabi-android-toolchain/bin/arm-linux-androideabi-ar
export RANLIB=/Users/panchen/Documents/test/test/openssl_for_ios_and_android-master/tools/armeabi-android-toolchain/bin/arm-linux-androideabi-ranlib
export STRIP=/Users/panchen/Documents/test/test/openssl_for_ios_and_android-master/tools/armeabi-android-toolchain/bin/arm-linux-androideabi-strip
export CPPFLAGS=
export CFLAGS=-mthumb -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64
export CXXFLAGS=-mthumb -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -std=c++11 -frtti -fexceptions
export LDFLAGS=
export LIBS=

checking OpenSSL linking with -ldl and -lpthread... no
checking for ssl_version in -laxtls... no
configure: WARNING: SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.
configure: WARNING: Use --with-ssl, --with-gnutls, --with-polarssl, --with-cyassl, --with-nss, --with-axtls, --with-winssl, or --with-darwinssl to address this.

configure: Configured to build curl/libcurl:

curl version: 7.59.0
Host setup: arm-unknown-linux-androideabi
Install prefix: /Users/panchen/Documents/test/test/openssl_for_ios_and_android-master/tools/libs/armeabi/usr/local
Compiler: /Users/panchen/Documents/test/test/openssl_for_ios_and_android-master/tools/armeabi-android-toolchain/bin/arm-linux-androideabi-clang
SSL support: no (--with-{ssl,gnutls,nss,polarssl,mbedtls,cyassl,axtls,winssl,darwinssl} )
SSH support: no (--with-libssh2)
zlib support: enabled
brotli support: no (--with-brotli)
GSS-API support: no (--with-gssapi)
TLS-SRP support: no (--enable-tls-srp)
resolver: POSIX threaded
IPv6 support: enabled
Unix sockets support: enabled
IDN support: no (--with-{libidn2,winidn})
Build libcurl: Shared=no, Static=yes
Built-in manual: no (--enable-manual)
--libcurl option: enabled (--disable-libcurl-option)
Verbose errors: no
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: no (--enable-rtsp)
RTMP support: no (--with-librtmp)
metalink support: no (--with-libmetalink)
PSL support: no (libpsl not found)
HTTP2 support: disabled (--with-nghttp2)
Protocols: FILE FTP HTTP TFTP

undefined reference to pthread function

我下載提供的libcrypto.a
編譯過不了,錯誤訊息
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function CRYPTO_THREAD_lock_new': (.text+0x25): undefined reference to pthread_rwlock_init'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function CRYPTO_THREAD_read_lock': (.text+0x55): undefined reference to pthread_rwlock_rdlock'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function CRYPTO_THREAD_write_lock': (.text+0x75): undefined reference to pthread_rwlock_wrlock'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function CRYPTO_THREAD_unlock': (.text+0x95): undefined reference to pthread_rwlock_unlock'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcrypto.a(threads_pthread.o): In function CRYPTO_THREAD_lock_free': (.text+0xba): undefined reference to pthread_rwlock_destroy'
下面是我的Android.mk
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := opensslcrypto
LOCAL_SRC_FILES := ../../../src/util/libcrypto.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := openssl
LOCAL_SRC_FILES := ../../../src/util/libssl.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := curl
LOCAL_SRC_FILES := ../../../src/util/libcurl.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := util
LOCAL_MODULE_FILENAME := $(prefix)_$(LOCAL_MODULE)

LOCAL_SRC_FILES := $(src_root)/util.cpp
LOCAL_SRC_FILES += $(src_root)/ecc.cpp
LOCAL_SRC_FILES += $(src_root)/ecdsa_sign.cpp

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../syslib/openssl/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../syslib/openssl/include/curl

LOCAL_STATIC_LIBRARIES := opensslcrypto
LOCAL_STATIC_LIBRARIES += openssl
LOCAL_STATIC_LIBRARIES += curl

LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)

LOCAL_CFLAGS := -fpermissive -w -pthread

LOCAL_LDLIBS := -lz

include $(BUILD_SHARED_LIBRARY)
我有加入-pthread一樣也過不了,請幫幫忙,謝謝

recompile with -fPIC

ld: error: relocation R_AARCH64_PREL64 cannot be used against symbol 'OPENSSL_armcap_P'; recompile with -fPIC

defined in C:/Users/lwx981510/Desktop/qiniu_upload/app/src/main/cpp/../jniLibs/arm64-v8a/libcrypto.a(armcap.o)

android arm64是否无法使用openssl?

您在文档中说明需要android-16以下api才能修复链接失败的问题,但同时您又提到低版本api不支持arm64,那是否意味着android arm64无法使用openssl呢?那您又编译openssl arm64版本的意义何在呢?

android studio CMake编译出错,直接用生成好的.a文件

用Android studio关联已经生成好的.a文件,编译出现如下错误:
Error:error: linker command failed with exit code 1 (use -v to see invocation)

CMakeLists.txt如下:

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)
#C++编译
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")

set(OpenSSL_DIR ${CMAKE_SOURCE_DIR}/keystore)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

add_library(crypto STATIC IMPORTED)
add_library(ssl STATIC IMPORTED)

set_target_properties( # Specifies the target library.
                       crypto

                       # Specifies the parameter you want to define.
                       PROPERTIES IMPORTED_LOCATION

                       # Provides the path to the library you want to import.
                       ${OpenSSL_DIR}/lib/${ANDROID_ABI}/libcrypto.a )


set_target_properties( # Specifies the target library.
                       ssl

                       # Specifies the parameter you want to define.
                       PROPERTIES IMPORTED_LOCATION

                       # Provides the path to the library you want to import.
                       ${OpenSSL_DIR}/lib/${ANDROID_ABI}/libssl.a )

add_library( # Sets the name of the library.
             keystore

             # Sets the library as a shared library.
             SHARED

             # Provides a relative path to your source file(s).
             src/main/cpp/keystore.cpp
             )

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
              log-lib

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              log )

include_directories( ${OpenSSL_DIR}/include )

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_include_directories(keystore PRIVATE
                           ${OpenSSL_DIR}/include)

target_link_libraries( # Specifies the target library.
                       keystore
                       crypto
                       ssl

                       # Links the target library to the log library
                       # included in the NDK.

                       ${log-lib} )

我的环境:
Android Studio 2.3.3
NDK:最新的ndk-bundle(应该是14r以上)

测试过程
1.猜想是路径不对,路径不对报的是其他的错,所以路径肯定没问题
2.Android PLATFORM版本有问题,是否需要设置版本?

NDK version supported and linker issue

Dear leenjewel,

kindly assist which NDK version I have use for build /build-openssl4android.sh

I tried with NDK-15 and g++ compiler

apps/ca.o: In function do_body': ca.c:(.text.unlikely+0x1108): undefined reference to stdin'
apps/openssl.o: In function main': openssl.c:(.text.startup+0x1c8): undefined reference to stpcpy'
openssl.c:(.text.startup+0x21c): undefined reference to signal' apps/ca.o: In function do_body':
ca.c:(.text.unlikely+0x1108): undefined reference to stdin' apps/openssl.o: In function main':
openssl.c:(.text.startup+0x1c8): undefined reference to stpcpy' openssl.c:(.text.startup+0x21c): undefined reference to signal'

:ui_openssl.c:function open_console: error: undefined reference to 'stdin'

问问 libcurl 版本

I'm building openssl for Android-16 and cURL for Android-21 as suggested in _shared.sh
I'm able to use openssl to en/decode messages, but when I call curl_easy_init() I get bunch of errors similar to this:

../../../../libs/x86/libcurl.a(libcurl_la-openssl.o):openssl.c:function ossl_recv: error: undefined reference to 'SSL_read'
  ../../../../libs/x86/libcurl.a(libcurl_la-openssl.o):openssl.c:function ossl_recv: error: undefined reference to 'SSL_get_error'
  ../../../../libs/x86/libcurl.a(libcurl_la-openssl.o):openssl.c:function ossl_connect_step2: error: undefined reference to 'SSL_connect'
  ../../../../libs/x86/libcurl.a(libcurl_la-openssl.o):openssl.c:function ossl_connect_step2: error: undefined reference to 'SSL_get_error'
  ../../../../libs/x86/libcurl.a(libcurl_la-openssl.o):openssl.c:function ossl_connect_step2: error: undefined reference to 'SSL_get_verify_result'
  ../../../../libs/x86/libcurl.a(libcurl_la-openssl.o):openssl.c:function ossl_connect_step2: error: undefined reference to 'X509_verify_cert_error_string'
  ../../../../libs/x86/libcurl.a(libcurl_la-openssl.o):openssl.c:function ossl_connect_step2: error: undefined reference to 'SSL_get0_alpn_selected'
...
...

Looks like cURL is looking for different version of openssl?

Can you elaborate on how do you mean using openssl api-16 while curl at api-21?

Thanks!

使用 BIO *bio = BIO_new(BIO_s_mem());时编译出错

使用楼主的编译方法得到的OpenSSL库,在使用函数 BIO *bio = BIO_new(BIO_s_mem());时编译出错,不能正常编译。Error:error: linker command failed with exit code 1 (use -v to see invocation)
已经查了一天了,定位到这行代码,但是试了作者给的各个版本都有这个问题,使用作者的demo工程同样也有这个问题,望解答。谢谢!

刚接触,有几个小问题!

1.文档写的是NDK_ROOT..sh里面写的是ANDROID_NDK.
2.那个你已经生成好的里面opensll/include/asn1_mac.h这个文件 #error "This file is obsolete; please update your software."
3.不管我用啥版本编译,最后都是(试了很多版本)
make (e=2): ϵͳ▒Ҳ▒▒▒ָ▒▒▒▒▒ļ▒▒▒
make[1]: *** [libcrypto.a] Error 2
make[1]: Leaving directory `D:/Android/openssl/tools/openssl-1.1.0f'
make: *** [all] Error 2
/d/Android/openssl/tools
/d/Android/openssl/tools/openssl-1.1.0f /d/Android/openssl/tools
4.最后找遍整个armeabi-android-toolchain目录也没有 libcrypto.a 和libssl.a.是应为上一步出错了么?
5.include目录下没有openssl目录.也是应为第三步出错了么?
新手小白,求指点!

openssl可以用 但是curl用不了 安卓下

安卓下刚开始提示"curl_rule_01 declared as an array with a negative size" 修改头文件后 又提示下边这个
怎么解决
Build command failed. Error while executing process /Users/xingyan/Library/Android/sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /Users/xingyan/Desktop/android-ndk-master/jniopenssldemo/app/.externalNativeBuild/cmake/debug/arm64-v8a --target native-lib} [1/3] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o [2/3] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/vpnservice.cpp.o /Users/xingyan/Desktop/android-ndk-master/jniopenssldemo/app/src/main/cpp/vpnservice.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ 1 warning generated. [3/3] Linking CXX shared library ../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libnative-lib.so FAILED: : && /Users/xingyan/Library/Android/android-ndk-r14b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android --gcc-toolchain=/Users/xingyan/Library/Android/android-ndk-r14b/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/xingyan/Library/Android/android-ndk-r14b/platforms/android-21/arch-arm64 -fPIC -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -O0 -fno-limit-debug-info -O0 -fno-limit-debug-info -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/vpnservice.cpp.o libMyAES.a libbase64.a ../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a ../../../../src/main/cpp/libs/arm64-v8a/lib/libssl.a ../../../../src/main/cpp/libs/arm64-v8a/lib/libcrypto.a -llog -lm "/Users/xingyan/Library/Android/android-ndk-r14b/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/libgnustl_static.a" && : ../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a(libcurl_la-version.o): In function Curl_version_init':
version.c:(.text.Curl_version_init+0x28): undefined reference to zlibVersion' version.c:(.text.Curl_version_init+0x70): undefined reference to zlibVersion'
../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a(libcurl_la-version.o): In function curl_version': version.c:(.text.curl_version+0x44): undefined reference to zlibVersion'
../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a(libcurl_la-version.o): In function curl_version_info': version.c:(.text.curl_version_info+0x20): undefined reference to zlibVersion'
../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a(libcurl_la-content_encoding.o): In function inflate_stream': content_encoding.c:(.text.inflate_stream+0x6c): undefined reference to inflate'
content_encoding.c:(.text.inflate_stream+0x8c): undefined reference to inflateEnd' content_encoding.c:(.text.inflate_stream+0xa0): undefined reference to inflateInit2_'
content_encoding.c:(.text.inflate_stream+0xc4): undefined reference to inflate' content_encoding.c:(.text.inflate_stream+0x13c): undefined reference to inflateEnd'
content_encoding.c:(.text.inflate_stream+0x198): undefined reference to inflateEnd' content_encoding.c:(.text.inflate_stream+0x1ac): undefined reference to inflateEnd'
content_encoding.c:(.text.inflate_stream+0x1ec): undefined reference to inflateEnd' content_encoding.c:(.text.inflate_stream+0x1fc): undefined reference to inflateEnd'
../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a(libcurl_la-content_encoding.o): In function Curl_unencode_deflate_write': content_encoding.c:(.text.Curl_unencode_deflate_write+0x68): undefined reference to inflateInit_'
../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a(libcurl_la-content_encoding.o): In function Curl_unencode_gzip_write': content_encoding.c:(.text.Curl_unencode_gzip_write+0x11c): undefined reference to zlibVersion'
content_encoding.c:(.text.Curl_unencode_gzip_write+0x144): undefined reference to inflateInit2_' content_encoding.c:(.text.Curl_unencode_gzip_write+0x188): undefined reference to inflateInit2_'
content_encoding.c:(.text.Curl_unencode_gzip_write+0x200): undefined reference to inflateEnd' content_encoding.c:(.text.Curl_unencode_gzip_write+0x23c): undefined reference to inflateEnd'
../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a(libcurl_la-content_encoding.o): In function Curl_unencode_cleanup': content_encoding.c:(.text.Curl_unencode_cleanup+0x1c): undefined reference to inflateEnd'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
`

Use openssl 1.1.1a get error

I get errors below when I use the compiled openssl library (version 1.1.1a) .

Build command failed.
Error while executing process D:\Android\sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build D:\work\Android\library\securitylib\securitylib\.externalNativeBuild\cmake\debug\armeabi-v7a --target security-lib}
[1/1] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\armeabi-v7a\libsecurity-lib.so
FAILED: cmd.exe /C "cd . && D:\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe  --target=armv7-none-linux-androideabi19 --gcc-toolchain=D:/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=D:/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -march=armv7-a -mthumb -Wa,--noexecstack -Wformat -Werror=format-security  -frtti -fexceptions -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -shared -Wl,-soname,libsecurity-lib.so -o ..\..\..\..\build\intermediates\cmake\debug\obj\armeabi-v7a\libsecurity-lib.so CMakeFiles/security-lib.dir/src/main/cpp/security-lib.cpp.o CMakeFiles/security-lib.dir/src/main/cpp/MyAES.cpp.o CMakeFiles/security-lib.dir/src/main/cpp/MyBASE64.cpp.o CMakeFiles/security-lib.dir/src/main/cpp/MyRSA.cpp.o -LD:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a -Wl,-Bstatic -lcrypto -lssl -Wl,-Bdynamic -llog -latomic -lm && cd ."
D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function zlib_stateful_init: error: undefined reference to 'inflateInit_'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function zlib_stateful_init: error: undefined reference to 'deflateInit_'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function zlib_stateful_finish: error: undefined reference to 'inflateEnd'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function zlib_stateful_finish: error: undefined reference to 'deflateEnd'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function zlib_stateful_compress_block: error: undefined reference to 'deflate'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function zlib_stateful_expand_block: error: undefined reference to 'inflate'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_write: error: undefined reference to 'deflateInit_'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_write: error: undefined reference to 'deflate'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_write: error: undefined reference to 'zError'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_read: error: undefined reference to 'inflateInit_'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_read: error: undefined reference to 'inflate'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_read: error: undefined reference to 'zError'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_ctrl: error: undefined reference to 'deflate'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_ctrl: error: undefined reference to 'zError'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_free: error: undefined reference to 'inflateEnd'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(c_zlib.o):c_zlib.c:function bio_zlib_free: error: undefined reference to 'deflateEnd'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(cryptlib.o):cryptlib.c:function OPENSSL_showfatal: error: undefined reference to 'stderr'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(eng_openssl.o):eng_openssl.c:function openssl_load_privkey: error: undefined reference to 'stderr'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(eng_openssl.o):eng_openssl.c:function test_rc4_init_key: error: undefined reference to 'stderr'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'tcgetattr'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'stdin'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'stderr'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function close_console: error: undefined reference to 'stdin'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'signal'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'

D:/work/Android/library/securitylib/securitylib/src/main/cpp/openssllib/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'

clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Environment info:

My platform: windows 10
ndk version: 20.0.5594570
app min sdk: 19
compile sdk: 29

Please help me.

need nghttp2 cpp compile for --enable-shared

Hi,

as your android arm64 curl build says "need nghttp2 cpp compile" for building shared curl lib, can you elaborate a little on this? How do you build nghttp2 in order to enable a shared curl lib for android arm64?

Thx

Compiling libcurl for android64-aarch64

Hi,

I can compile openssl for android-armeabi and android64-aarch64 no problem. Btw I think your documentation is wrong on the homepage:

It reads

sh ./build-openssl4android.sh android64-arm64 #for arm64_v8a

but I think it should read:

sh ./build-openssl4android.sh android64-aarch64 #for arm64_v8a

I can also compile libcurl for android-armeabi but for android64-aarch64 the configuration step errors out. I see errors in the config.log file for libcurl:
config.log

I've modified the _shared.sh file as follows:

ANDROID_API=${ANDROID_API:-21}
ARCHS=("android-armeabi" "android64-aarch64")
ABIS=("armeabi-v7a" "arm64-v8a")

And I'm compiling openssl openssl-1.1.0g and libcurl curl-7.56.1 although I do not think this are the cause of this particular problem. I'm also using Android SDK 28 and NDK 14b.

Please let me know what you think.

APK包的问题

问下楼主:
openssl这么大的一个库,不做修改直接编译,然后又以静态库依赖,那导入到apk中,会让apk变大多少?
这个大小是不是超出了承受范围.

编译curl时32位架构都编译不出来

netrc.c: In function 'Curl_parsenetrc':
netrc.c:80:7: error: implicit declaration of function 'getpwuid_r' [-Werror=implicit-function-declaration]
if(!getpwuid_r(geteuid(), &pw, pwbuf, sizeof(pwbuf), &pw_res)
^
cc1: some warnings being treated as errors
make[2]: *** [libcurl_la-netrc.lo] Error 1

同样的错误,似乎是pwd.h的头文件没有被引入,受HAVE_PWD_H宏控制,但是64位的都能过

求教 curl添加对HTTP3(quiche)支持时遇到问题~

非常棒的工具 !它让我少走了很多弯路 ,并且通过参考完成了其他项目的编译。但是我在编译curl的quiche支持时遇到了问题,他提示我configure: error: --with-quiche was specified but could not find quiche pkg-config file.
我不在到该如何处理它,quiche是由其他语言和工具构建编译的 无法套用现有模板,我手动完成了编译并参考本项目编译出来的结果进行组装如下图 他还是告诉我找不到pkg-config file

求大佬施法操作撸一波教程或脚本,求躺赢~ 拜谢orz~ 感激不尽~

image

关于lib文件夹的问题

您好,我编译生成了一个output文件夹,和tools同级,tools下有一个libs文件夹,我想问下,我该把那个下面的armeabi复制到AndroidStudio工程呢?还有就是include/openssl该放到哪里?非常感谢

Cant link against the libarary

Hello !
I'm building ffmpeg for android with openssl.
I couldn't get the configuration to work - i have tried compiling with the script, and using the prebuild one.

I am working with the x86 build.

Here is the code ffmpeg tests for openssl support :

extern int SSL_library_init();
int main(void){ SSL_library_init(); }

Then we try to compile this code, using android's gcc, and including the prebuild headers and actual lib.
OPEN_SSL is /output/android/openssl-android-x86 From the prebuild zip.

Here is compiling the code.

$NDK_ROOT/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc 
--sysroot=$NDK_ROOT/platforms/android-9/arch-x86/ 
-isysroot $NDK_ROOT/platforms/android-9/arch-x86/ 
-D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -m32 -fPIE 
-I$OPEN_SSL/include 
-std=c99 -fomit-frame-pointer -fPIC -pthread -c 
-o test.o test.c

Note the -I header option.
This command works fine, and produces test.o, now we link it to the actual lib:

$NDK_ROOT/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc
-m32 -Wl,-eh-frame-hdr -Wl,-m,elf_i386 -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -fPIE -pie 
-L$OPEN_SSL/lib
--sysroot=$NDK_ROOT/platforms/android-9/arch-x86/ 
-isysroot$NDK_ROOT/platforms/android-9/arch-x86/ 
-Wl,--as-needed -Wl,-z,noexecstack 
-o test test.o 
-lssl -lgdi32 -lm -pthread

Note the -L libs option.
This command fails, with this error :

test.o:test.c:function main: error: undefined reference to 'SSL_library_init'
collect2: error: ld returned 1 exit status

I know its not a problem with ffmpeg configuration because the same code works with this openssl prebuild : https://github.com/emileb/OpenSSL-for-Android-Prebuilt.

What is going on ? Why this one isn't working ?
You have done a great work with the scripts providing a convenient way to build, and i would like to use it.

ndk-r15

Hi,
Thanks for this project, it's very helpful.
I just wanted to let you know that it actually works if you build with ndk-r15, you just have to build the toolchain with the argument "--deprecated-headers".
Cheers!

[REQUEST] provide .pc files

I'm trying to use your precompiled binaries in my ffmpeg for android build...

but in order to let ffmpeg know i've the dependencies for openssl i need the .pc files created after build it...

could you include these files in the prebuilt files you release?

I tried to include you script under mine and generate it on the fly but it is not working as expected and in order to avoid an extra unecessary complication i would appreciate so much if you could provide me these files

thankyou

*.log: No such file or directory

When I try to run sh build-android-openssl.sh arm (or any other build command for that matter), I got this following error

build-android-curl.sh: line 117: openssl_for_ios_and_android/tools/../output/android/curl-armeabi-v7a/log/armeabi-v7a.log: No such file or directory

image

The destination folders were created correctly, but there is no file in it

mac上执行 ./build-openssl4android.sh有问题,帮忙看一下


./build-openssl4android.sh: line 46: ./Configure: No such file or directory
make: *** No targets specified and no makefile found. Stop.
./build-openssl4android.sh: line 67: popd: directory stack empty
tar: Error opening archive: Failed to open 'openssl-1.0.2k.tar.gz'
./build-openssl4android.sh: line 31: pushd: openssl-1.0.2k: No such file or directory


unbound variable

$ sh ./build-openssl4android.sh
./_shared.sh: line 20: 1: unbound variable

if [ "${1}" == "cURL" ]; then // 这是第20行
ANDROID_API=${ANDROID_API:-21}
else
ANDROID_API=${ANDROID_API:-16}
fi
ARCHS=("android" "android-armeabi" "android-x86" "android-mips")
ABIS=("armeabi" "armeabi-v7a" "x86" "mips")

找不到zlib?

请问cmakelist里面需要加和zlib有关的项目吗?我这里一直没有办法运行:
image
谢谢~

Build Command for Ubuntu17.10

Hi,
I am building OpenSSL for android on Ubuntu 17.10.
1st I tried to run 'build-curl4android.sh' but getting error as below:
image

and when run the 'build-openssl4android.sh android-armeabi' then
image

I am using tools as listed below:

  • openssl-1.1.0f.tar.gz
  • curl-7.53.1.tar.gz
  • android-ndk-r14b

Please advise me what are parameters need to pass i.e.
ARCH=$1; OUT=$2; CLANG=${3:-""};

Your input will helpful to me.
Thanks ,
Dinesh

clang70: error: unknown argument: '-mandroid'

Hello,

I'm compiling openssl for Android on Linux.
I'm getting the following error:

clang70: error: unknown argument: '-mandroid'

I could not find any -mandroid tags in .sh files. How can I remove this from command line?
OR Can you share a recent release for android 32 and 64 bit libraries for latest NDK?

/home/reveng/openssl/openssl_for_ios_and_android/tools/armeabi-android-toolchain/bin/arm-linux-androideabi-gcc  -I. -Icrypto/include -Iinclude -I/home/reveng/openssl/openssl_for_ios_and_android/tools/armeabi-android-toolchain/sysroot/usr/include -DZLIB -DDSO_DLFCN -DHAVE_DLFCN_H -DNDEBUG -DOPENSSL_THREADS -DOPENSSL_NO_DYNAMIC_ENGINE -DOPENSSL_PIC -DOPENSSLDIR="\"/home/reveng/openssl/openssl_for_ios_and_android/tools/libs/armeabi/ssl\"" -DENGINESDIR="\"/home/reveng/openssl/openssl_for_ios_and_android/tools/libs/armeabi/lib/engines-1.1\"" -Wall -O3 -pthread -mandroid -fPIC --sysroot=/home/reveng/openssl/openssl_for_ios_and_android/tools/armeabi-android-toolchain/sysroot -Wa,--noexecstack  -fPIC -DOPENSSL_USE_NODELETE -MMD -MF crypto/aes/aes_ecb.d.tmp -MT crypto/aes/aes_ecb.o -c -o crypto/aes/aes_ecb.o crypto/aes/aes_ecb.c
clang70: error: unknown argument: '-mandroid'
make[1]: *** [crypto/aes/aes_cbc.o] Error 1
make[1]: *** Waiting for unfinished jobs....
clang70: error: unknown argument: '-mandroid'
make[1]: *** [crypto/aes/aes_cfb.o] Error 1
clang70: error: unknown argument: '-mandroid'
clang70: error: unknown argument: '-mandroid'
make[1]: *** [crypto/aes/aes_ecb.o] Error 1
make[1]: *** [crypto/aes/aes_core.o] Error 1

链接失败

Build command failed.
Error while executing process C:\Users\[REMOVED]\AppData\Local\Android\Sdk\cmake\3.10.2.4988404\bin\cmake.exe with arguments {--build [REMOVED]\app\.externalNativeBuild\cmake\debug\arm64-v8a --target security}
[1/3] Building CXX object CMakeFiles/security.dir/util.cpp.o
[2/3] Building CXX object CMakeFiles/security.dir/security.cpp.o
[3/3] Linking CXX shared library [REMOVED]\app\build\intermediates\cmake\debug\obj\arm64-v8a\libsecurity.so
FAILED: [REMOVED]/app/build/intermediates/cmake/debug/obj/arm64-v8a/libsecurity.so 
cmd.exe /C "cd . && C:\Users\[REMOVED]\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android21 --gcc-toolchain=C:\Users\[REMOVED]\AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:\Users\[REMOVED]\AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security  -frtti -fexceptions -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -shared -Wl,-soname,libsecurity.so -o [REMOVED]\app\build\intermediates\cmake\debug\obj\arm64-v8a\libsecurity.so CMakeFiles/security.dir/security.cpp.o CMakeFiles/security.dir/util.cpp.o  -llog [REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a [REMOVED]/app/src/main/jni/../libs/arm64-v8a/libssl.a -latomic -lm && cd ."
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
c_zlib.c:(.text+0x7c): undefined reference to `inflateInit_'
c_zlib.c:(.text+0xa8): undefined reference to `deflateInit_'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
c_zlib.c:(.text+0x104): undefined reference to `inflateEnd'
c_zlib.c:(.text+0x10c): undefined reference to `deflateEnd'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `zlib_stateful_compress_block':
c_zlib.c:(.text+0x164): undefined reference to `deflate'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `zlib_stateful_expand_block':
c_zlib.c:(.text+0x1d8): undefined reference to `inflate'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
c_zlib.c:(.text+0x318): undefined reference to `deflateInit_'
c_zlib.c:(.text+0x3b0): undefined reference to `deflate'
c_zlib.c:(.text+0x3dc): undefined reference to `zError'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
c_zlib.c:(.text+0x4e8): undefined reference to `inflateInit_'
c_zlib.c:(.text+0x524): undefined reference to `inflate'
c_zlib.c:(.text+0x5ac): undefined reference to `zError'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
c_zlib.c:(.text+0x78c): undefined reference to `deflate'
c_zlib.c:(.text+0x86c): undefined reference to `zError'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
c_zlib.c:(.text+0x954): undefined reference to `inflateEnd'
c_zlib.c:(.text+0x978): undefined reference to `deflateEnd'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(cryptlib.o): In function `OPENSSL_showfatal':
cryptlib.c:(.text+0x2c): undefined reference to `stderr'
cryptlib.c:(.text+0x34): undefined reference to `stderr'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(eng_openssl.o): In function `openssl_load_privkey':
eng_openssl.c:(.text+0x350): undefined reference to `stderr'
eng_openssl.c:(.text+0x354): undefined reference to `stderr'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(eng_openssl.o): In function `test_rc4_init_key':
eng_openssl.c:(.text+0x534): undefined reference to `stderr'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(eng_openssl.o):eng_openssl.c:(.text+0x538): more undefined references to `stderr' follow
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(ui_openssl.o): In function `open_console':
ui_openssl.c:(.text+0x68): undefined reference to `stdin'
ui_openssl.c:(.text+0x6c): undefined reference to `stdin'
ui_openssl.c:(.text+0x9c): undefined reference to `stderr'
ui_openssl.c:(.text+0xa0): undefined reference to `stderr'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(ui_openssl.o): In function `close_console':
ui_openssl.c:(.text+0x374): undefined reference to `stdin'
ui_openssl.c:(.text+0x378): undefined reference to `stdin'
ui_openssl.c:(.text+0x3a0): undefined reference to `stderr'
ui_openssl.c:(.text+0x3a4): undefined reference to `stderr'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

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.