2

I'm working on an Android NDK project, and I would like to use the libcurl library to download resources from C++. I am using the NDK's built-in ndk-build tool. During build, I get the following error:

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:  

Here is my 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)

I have downloaded the curl/libcurl release and placed it in the src/main/cpp/ directory. I'm looking for a way to include libcurl in the project. To be clear, I want to use the official libcurl release (not a ported version).

Andrew Farm
  • 178
  • 1
  • 14

1 Answers1

-1

I didn't succeed in compiling libcurl from source, but I did find this link which includes static libcurl binaries pre-built for Android (also includes iOS binaries).

For posterity, here is (part of) my new 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)

################################
Andrew Farm
  • 178
  • 1
  • 14