2

i need libcurl to do something in dropbox djinni mx3 project; But when i create libmx3_android.so then show this error message: "undefined reference to 'curl_easy_init'"...... Because i can not link libcurl.a to this project.

for android jni, i find some solution can solve it; That is to eidt Android.mk

include $(CLEAR_VARS)
LOCAL_MODULE:= libcurl
LOCAL_SRC_FILES := libcurl.a
LOCAL_EXPORT_C_INCLUDES := /* put the path to the Curl headers here */
include $(PREBUILT_STATIC_LIBRARY)

but in these project, .mk file will recreate by mx3.gyp. how to edit mx3.gyp to create that .mk file?

thx.

ttycode
  • 21
  • 1

2 Answers2

3

first of all, you will need the .a file compiled for all platform. you can find it here https://github.com/gcesarmza/curl-android-ios or compile yourself. Then you will also need to add as dependency

"targets": [
    {
        "target_name": "libapplication_jni",
        "type": "shared_library",
        "dependencies": [
          "../support-lib/support_lib.gyp:djinni_jni",
        ],
        "libraries": ["libcurl.a",],
        "ldflags": [ "-llog", "-lz", "-Wl,--build-id,--gc-sections,--exclude-libs,ALL" ],
        "sources": [
          "../support-lib/jni/djinni_main.cpp",
          "<!@(python glob.py generated-src/jni   '*.cpp')",
          "<!@(python glob.py handwritten-src/cpp '*.cpp')",
        ],
        "include_dirs": [
          "../deps/include",
          "generated-src/jni",
          "generated-src/cpp",
          "handwritten-src/jni",
          "handwritten-src/cpp",
        ],
    },
],

place your curl include files in the deps/include directory Lastly, place this at the begining of your Android.mk file

LOCAL_PATH:= $(call my-dir)

#ARM optimizations
ifeq ($(TARGET_ARCH),arm)
  PLATFORM_TARGET_ARCH := armeabi
endif
ifeq ($(TARGET_ARCH),arm64)
  PLATFORM_TARGET_ARCH := arm64-v8a
endif

#x86 optimizations
ifeq ($(TARGET_ARCH),x86)
  PLATFORM_TARGET_ARCH := x86
endif
ifeq ($(TARGET_ARCH),x86_64)
  PLATFORM_TARGET_ARCH := x86_64
endif

#MIPS optimizations
ifeq ($(TARGET_ARCH),mips)
  PLATFORM_TARGET_ARCH := mips
endif
ifeq ($(TARGET_ARCH),mips64)
  PLATFORM_TARGET_ARCH := mips64
endif

include $(CLEAR_VARS)
LOCAL_MODULE:= libcurl
LOCAL_SRC_FILES := /djinni/mobile/deps/prebuilt/android/$(PLATFORM_TARGET_ARCH)/libcurl.a
LOCAL_EXPORT_C_INCLUDES := /djinni/mobile/deps/include
include $(PREBUILT_STATIC_LIBRARY)

i hope it helps. thanks

0

'ldflags' : [ '-L$(LOCAL_PATH)/deps/curl', '-L$(LOCAL_PATH)/deps/zlib', '-llog' , '-lcurl', '-lz'],

ttycode
  • 21
  • 1