2017-06-12 130 views
0

我正在開發一個Android NDK項目,並且我想使用libcurl庫從C++下載資源。我正在使用NDK的內置ndk-build工具。在生成過程中,我得到以下錯誤:在Android NDK中使用libcurl

Build command failed. 
Error while executing process /Users/afarm/Library/Android/sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/afarm/AndroidStudioProjects/NativeOpenGL/engine/Android.mk APP_ABI=armeabi NDK_ALL_ABIS=armeabi NDK_DEBUG=1 APP_PLATFORM=android-15 NDK_OUT=/Users/afarm/AndroidStudioProjects/NativeOpenGL/engine/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/Users/afarm/AndroidStudioProjects/NativeOpenGL/engine/build/intermediates/ndkBuild/debug/lib APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n} 
Android NDK: /Users/afarm/AndroidStudioProjects/NativeOpenGL/engine/Android.mk: Cannot find module with tag 'libcurl' in import path  
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?  
Android NDK: The following directories were searched:  
Android NDK: 

這裏是我的Android.mk:

LOCAL_PATH := $(call my-dir) 

include $(CLEAR_VARS) 

LOCAL_MODULE := engine-core 
LOCAL_CFLAGS := -Wall -Wextra 
APP_CPPFLAGS := -std=c++11 
APP_STL := gnustl_static 
NDK_TOOLCHAIN_VERSION := clang 
LOCAL_SRC_FILES := src/main/cpp/rendererwrapper.cpp \ 
        src/main/cpp/renderer.cpp \ 
        src/main/cpp/ShaderProgram.cpp \ 
        src/main/cpp/SimpleShaderProgram.cpp \ 
        src/main/cpp/NativeOpenGLShaderPrograms.c 
LOCAL_STATIC_LIBRARIES := libcurl 
LOCAL_LDLIBS := -llog -lGLESv2 -landroid 

include $(BUILD_SHARED_LIBRARY) 

$(call import-add-path,src/main/cpp) 
$(call import-module,libcurl) 

我已經下載了捲曲/ libcurl的版本,把它在src /主/ CPP /目錄。我正在尋找一種將libcurl包含在項目中的方法。要清楚,我想使用官方的libcurl版本(不是移植版本)。

回答

0

我沒有成功從源代碼編譯libcurl,但我確實發現了this link,其中包含爲Android預先構建的靜態libcurl二進制文件(還包括iOS二進制文件)。

對於後人,這裏是(部分)我的新Android.mk:

LOCAL_PATH := $(call my-dir) 

################################ 
# Prepare libcurl 

include $(CLEAR_VARS) 

LOCAL_MODULE := libcurl 
LOCAL_SRC_FILES := libs/libcurl/$(TARGET_ARCH_ABI)/libcurl.a 
LOCAL_EXPORT_C_INCLUDES := libs/libcurl/include 

include $(PREBUILT_STATIC_LIBRARY) 

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

################################ 
# Build engine 

include $(CLEAR_VARS) 

LOCAL_MODULE := engine-core 
LOCAL_CFLAGS := -Wall -Wextra 
LOCAL_CPPFLAGS := -std=c++11 
LOCAL_SRC_FILES := src/main/cpp/rendererwrapper.cpp \ 
        src/main/cpp/renderer.cpp \ 
        src/main/cpp/ShaderProgram.cpp \ 
        src/main/cpp/SimpleShaderProgram.cpp \ 
        src/main/cpp/NativeOpenGLShaderPrograms.c 
LOCAL_STATIC_LIBRARIES := libcurl 
LOCAL_LDLIBS := -llog -lGLESv2 -landroid 

include $(BUILD_SHARED_LIBRARY) 

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