2015-09-25 52 views
2

我需要libcurl在Dropbox djinni mx3項目中做些事情; 但是,當我創建libmx3_android.so然後顯示此錯誤消息: 「未定義引用'curl_easy_init'」...... 因爲我無法將libcurl.a鏈接到此項目。如何在Dropbox中鏈接libcurl djinni項目

對於Android jni,我發現一些解決方案可以解決它;這是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) 

但在這些項目中,.mk文件將被mx3.gyp重建。 如何編輯mx3.gyp來創建.mk文件?

thx。

回答

0

'LDFLAGS':[ '-L $(LOCAL_PATH)/ DEPS /捲曲', '-L $(LOCAL_PATH)/ DEPS/ZLIB', '-llog', '-lcurl', '-lz'],

2

首先,您需要爲所有平臺編譯.a文件。你可以在這裏找到https://github.com/gcesarmza/curl-android-ios或編譯自己。 那麼你還需要添加爲依賴

"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", 
      "<[email protected](python glob.py generated-src/jni '*.cpp')", 
      "<[email protected](python glob.py handwritten-src/cpp '*.cpp')", 
     ], 
     "include_dirs": [ 
      "../deps/include", 
      "generated-src/jni", 
      "generated-src/cpp", 
      "handwritten-src/jni", 
      "handwritten-src/cpp", 
     ], 
    }, 
], 

地方你的捲曲包括在DEPS文件/ include目錄 最後,把這個在你的Android.mk的開頭文件

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) 

我希望能幫助到你。謝謝