问题
I want to use libcurl in my native project. How can I integrate this library and build using ndk? Is there any post available that can guide me through the process?
I tried the docs from official site, but that's not working. FYI I am on windows platform.
回答1:
Create a JNI folder within your project and add a folder for each architecture(arm, armv7,x86 etc). Place the corresponding libcurl.so files in the respective folders. Since this is a rebuilt shared binary you need to add this to your Android.mk file
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := <Curl> //add the module name here.
LOCAL_SRC_FILES := <libCurl.so> //add the .so file name here
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../jni/include
include $(PREBUILT_SHARED_LIBRARY)
Create a JNI C file that uses the libraries from Curl and call the native code from Java source.
static {
System.loadLibrary("curl");
}
It shouldnt make a difference if you are on Windows platform. Adding open source liv files to Android NDK is pretty much the same process on all platforms.
回答2:
No idea about windows, but as to the linker magic, see the links in Integrating MuPDF as a library project (Android)
来源:https://stackoverflow.com/questions/25379630/how-to-integrate-libcurl-in-native-android-project-and-build-using-ndk-on-window