leenjewel / openssl_for_ios_and_android

OpenSSL Library for iOS and Android
920 stars 317 forks source link

undefined reference to pthread function #37

Closed chewang1 closed 5 years ago

chewang1 commented 5 years ago

我下載提供的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 topthread_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 topthread_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 topthread_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 topthread_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 topthread_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_MODULEFILENAME := $(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一樣也過不了,請幫幫忙,謝謝

leenjewel commented 5 years ago

This may be helpful to you

Android supports pthreads strating from API 9 version. i got the above error due to i am using old version of NDK. to avoid this build like this "$ndk-build APP_PLATFORM=android-9 "

chewang1 commented 5 years ago

謝謝,解決了,改用ndk r11就能過了