gustavogenovese / curl-android-ios

Static libcurl to be used in Android and iOS apps. Build scripts included. No Android source required
641 stars 255 forks source link

NDK libcurl.a - undefined reference to 'Curl_xxx' #29

Closed InfiniteStates closed 8 years ago

InfiniteStates commented 8 years ago

I'm trying to link against the pre-built static libraries for both iOS and Android.

The iOS side is working well (thanks 👍 ) but the Android side is failing no matter what I do.

(Note - the Android sample app in the repo also fails the build with the same errors)

libcurl.a(url.o):function Curl_disconnect: error: undefined reference to 'Curl_http_ntlm_cleanup' libcurl.a(http.o):function output_auth_headers: error: undefined reference to 'Curl_output_ntlm' libcurl.a(http.o):function Curl_http_input_auth: error: undefined reference to 'Curl_auth_is_ntlm_supported' libcurl.a(http.o):function Curl_http_input_auth: error: undefined reference to 'Curl_input_ntlm' libcurl.a(http.o):function Curl_http_input_auth: error: undefined reference to 'Curl_auth_is_digest_supported' libcurl.a(http_digest.o):function Curl_input_digest: error: undefined reference to 'Curl_auth_decode_digest_http_message' libcurl.a(http_digest.o):function Curl_output_digest: error: undefined reference to 'Curl_auth_create_digest_http_message' libcurl.a(http_digest.o):function Curl_digest_cleanup: error: undefined reference to 'Curl_auth_digest_cleanup' libcurl.a(http_digest.o):function Curl_digest_cleanup: error: undefined reference to 'Curl_auth_digest_cleanup' libcurl.a(curl_sasl.o):function Curl_sasl_cleanup: error: undefined reference to 'Curl_auth_ntlm_cleanup' libcurl.a(curl_sasl.o):function Curl_sasl_start: error: undefined reference to 'Curl_auth_is_digest_supported' libcurl.a(curl_sasl.o):function Curl_sasl_start: error: undefined reference to 'Curl_auth_is_ntlm_supported' libcurl.a(curl_sasl.o):function Curl_sasl_start: error: undefined reference to 'Curl_auth_create_ntlm_type1_message' libcurl.a(curl_sasl.o):function Curl_sasl_start: error: undefined reference to 'Curl_auth_create_external_message' libcurl.a(curl_sasl.o):function Curl_sasl_start: error: undefined reference to 'Curl_auth_create_oauth_bearer_message' libcurl.a(curl_sasl.o):function Curl_sasl_start: error: undefined reference to 'Curl_auth_create_oauth_bearer_message' libcurl.a(curl_sasl.o):function Curl_sasl_start: error: undefined reference to 'Curl_auth_create_plain_message' libcurl.a(curl_sasl.o):function Curl_sasl_start: error: undefined reference to 'Curl_auth_create_login_message' libcurl.a(curl_sasl.o):function Curl_sasl_continue: error: undefined reference to 'Curl_auth_create_plain_message' libcurl.a(curl_sasl.o):function Curl_sasl_continue: error: undefined reference to 'Curl_auth_create_login_message' libcurl.a(curl_sasl.o):function Curl_sasl_continue: error: undefined reference to 'Curl_auth_create_login_message' libcurl.a(curl_sasl.o):function Curl_sasl_continue: error: undefined reference to 'Curl_auth_create_external_message' libcurl.a(curl_sasl.o):function Curl_sasl_continue: error: undefined reference to 'Curl_auth_decode_cram_md5_message' libcurl.a(curl_sasl.o):function Curl_sasl_continue: error: undefined reference to 'Curl_auth_create_cram_md5_message' libcurl.a(curl_sasl.o):function Curl_sasl_continue: error: undefined reference to 'Curl_auth_create_digest_md5_message' libcurl.a(curl_sasl.o):function Curl_sasl_continue: error: undefined reference to 'Curl_auth_create_ntlm_type1_message' libcurl.a(curl_sasl.o):function Curl_sasl_continue: error: undefined reference to 'Curl_auth_decode_ntlm_type2_message' libcurl.a(curl_sasl.o):function Curl_sasl_continue: error: undefined reference to 'Curl_auth_create_ntlm_type3_message' libcurl.a(curl_sasl.o):function Curl_sasl_continue: error: undefined reference to 'Curl_auth_create_oauth_bearer_message' libcurl.a(curl_sasl.o):function Curl_sasl_continue: error: undefined reference to 'Curl_auth_create_oauth_bearer_message'

Is there an additional library I need to be linking against?

I'm using Android Studio 2.2.1 and have tried building against NDKs r10e and r13...

jsuppe commented 8 years ago

I am having the same issue, using ndk-r10e

YjyJeff commented 8 years ago

I am having the same issue when I execute the android test, the ndk version is 13.0.3315539 , and the android studio version is 2.2. I tried to use this lib in Cmake, here is my CMakeLists.txt: cmake_minimum_required(VERSION 3.4.1) add_library( native-lib SHARED src/main/cpp/native-lib.cpp ) find_library( log-lib log ) include_directories(/home/yjy/tools/curl-android-ios/curl/include/) target_link_libraries( native-lib ${log-lib} /home/yjy/tools/curl-android-ios/prebuilt-with-ssl/android/mips64/libcurl.a) However, I got the same issues. How can I solve it ? Thanks in advance !

MarcelKlammer commented 8 years ago

Same here. No luck whatever I try.

MarcelKlammer commented 8 years ago

The changes in the pull request helped with this problem.

InfiniteStates commented 8 years ago

Did you manage to link against the library successfully then?

MarcelKlammer commented 8 years ago

I applied the provided patch (only 4 lines to change) to the curl.mk file.

My goal was to create library that uses curl internally.

So before building my lib I put (only need x86 and armeabi-v7a for my Adobe AIR native extension):

###############################

libcurl.a

include $(CLEAR_VARS)

LOCAL_MODULE := curl_static

ifeq ($(TARGET_ARCH_ABI), $(filter $(TARGET_ARCH_ABI), x86)) LOCAL_SRC_FILES := path/to/curl-android-ios/prebuilt-with-ssl/android/x86/libcurl.a endif

ifeq ($(TARGET_ARCH_ABI), $(filter $(TARGET_ARCH_ABI), armeabi-v7a)) LOCAL_SRC_FILES := path/to/curl-android-ios/prebuilt-with-ssl/android/armeabi-v7a/libcurl.a endif

ifeq ($(TARGET_ARCH_ABI),armeabi) LOCAL_SRC_FILES := path/to/curl-android-ios/prebuilt-with-ssl/android/armeabi/libcurl.a endif

LOCAL_EXPORT_C_INCLUDES := path/to/curl-android-ios/prebuilt-with-ssl/android/include LOCAL_C_INCLUDES := path/to/curl-android-ios/prebuilt-with-ssl/android/include

include $(PREBUILT_STATIC_LIBRARY)

###############################

Then for my lib I set:

LOCAL_STATIC_LIBRARIES := curl_static

Cheers Marcel

jsuppe commented 8 years ago

I was able to apply the changes from pull request #27 and was able to compile and then link libcurl.a to my project for armeabi-v7a and arm64-v8a successfully.

For my purposes I had used android-ndk-r10e and had changed the TARGET variable in the script to use android-21.

InfiniteStates commented 8 years ago

Awesome, thanks guys - yep, until PR 27 gets merged in, this will get you up and running again on the Android side :)

git pull origin pull/27/head

winster commented 7 years ago

Great! Pull 27 worked! Wondering why is it not merged to master!!