6

I try to compile openssl 1.0.2h in my project

I made those steps for use Openssl

To add the libraries to my project as prebuilt static libraries, I created an openssl folder under my jni directory containing lib/ (which contain the .a files for the architectures I support), include/ which has the necessary includes (you can find that under the openssl version you downloaded) and Android.mk which has the following:

include $(CLEAR_VARS) 
LOCAL_MODULE := libssl
LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libssl.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libcrypto
LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libcrypto.a
include $(PREBUILT_STATIC_LIBRARY)

Then, to use the library within another jni module I added the following to its Android.mk file:

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../openssl/include
LOCAL_STATIC_LIBRARIES := libssl libcrypto

and I get this:

jni/openssl/lib/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigfillset'
jni/openssl/lib/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset'
jni/openssl/lib/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset'
jni/openssl/lib/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset'
jni/openssl/lib/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset'
jni/openssl/lib/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'tcgetattr'
jni/openssl/lib/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'signal'
jni/openssl/lib/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'
jni/openssl/lib/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'
collect2: error: ld returned 1 exit status
make[1]: *** [obj/local/armeabi-v7a/libpjsipjni.so] Error 1
make[1]: *** Waiting for unfinished jobs....
jni/openssl/lib/armeabi/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'tcgetattr'
jni/openssl/lib/armeabi/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'signal'
jni/openssl/lib/armeabi/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'
jni/openssl/lib/armeabi/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'
collect2: error: ld returned 1 exit status
make[1]: *** [obj/local/armeabi/libpjsipjni.so] Error 1
jni/openssl/lib/x86/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'tcgetattr'
jni/openssl/lib/x86/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'signal'
jni/openssl/lib/x86/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'
jni/openssl/lib/x86/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'
collect2: error: ld returned 1 exit status
make[1]: *** [obj/local/x86/libpjsipjni.so] Error 1
jni/openssl/lib/mips/libcrypto.a(ui_openssl.o): In function `open_console':
ui_openssl.c:(.text.open_console+0xb4): undefined reference to `tcgetattr'
jni/openssl/lib/mips/libcrypto.a(ui_openssl.o): In function `read_string_inner':
ui_openssl.c:(.text.read_string_inner+0xf0): undefined reference to `signal'
ui_openssl.c:(.text.read_string_inner+0x2c0): undefined reference to `tcsetattr'
ui_openssl.c:(.text.read_string_inner+0x39c): undefined reference to `tcsetattr'
collect2: error: ld returned 1 exit status

Please, I need help

Community
  • 1
  • 1
  • 2
    I think you have a bigger problem. You need to configure each platform separately using OpenSSL's `./config` program, but its not clear to me you have done that. The `config` step will produce a unique `opensslconf.h` and `bn.h` for the platform. Also see [Build Multiarch OpenSSL on OS X](http://stackoverflow.com/a/25531033/608639). Its a different platform, but its the same problem. – jww Jul 04 '16 at 23:44
  • Thanks. I changed the Configure file and recompiled the openssl library for each arch and with this I fixed the problem. – Silviano Angel Jul 05 '16 at 17:21
  • Would you please mention what changes you made to the Configure file? I have previously built and included 1.0.2g successfully without any changes to the Configure file (after I run the config script I see "Configured for android-armv7") so I'm not sure what I'm doing wrong here – Nonos Aug 19 '16 at 19:57
  • 3
    Whoops, turns out I had a different issue. I was building for android-24 which is my target sdk instead of building for 19 which is the minimum sdk and more importantly the APP_PLATFORM in my Application.mk, once I rebuilt for android-19 things went fine from there. Credit goes to this answer: http://stackoverflow.com/a/37123859/1098917 – Nonos Aug 19 '16 at 20:26
  • Thanks @Nonos I had the same problem as you (with different versions). Even though my build.gradle specified a minSdkVersion of 21 and I was setting version 21 in a bunch of other places, my Application.mk still had an APP_PLATFORM of "android-15" and because of this I was getting these undefined reference errors. – André Morujão Sep 18 '17 at 15:34

0 Answers0