我需要libcurl在dropbox djinni mx3项目中做一些事情; 但是,当我创建libmx3_android.so然后显示此错误消息: "未定义参考' curl_easy_init'" ...... 因为我无法将libcurl.a链接到这个项目。
对于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 :(得分:3)
首先,您需要为所有平台编译的.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",
"<!@(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",
],
},
],
将curl包含文件放在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)
我希望它有所帮助。感谢
答案 1 :(得分:0)
&#39; LDFLAGS&#39; :[ &#39; -L $(LOCAL_PATH)/ DEPS /卷曲&#39 ;, &#39; -L $(LOCAL_PATH)/ DEPS / zlib的&#39 ;, &#39; -llog&#39; , &#39; -lcurl&#39 ;, &#39; -lz&#39;],