如何在本地android项目中集成libcurl并在Windows上使用ndk进行构建? [英] How to integrate libcurl in native android project and build using ndk on windows?
问题描述
我想在本机项目中使用libcurl.如何集成该库并使用ndk进行构建?有没有可用的帖子可以指导我完成整个过程?
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?
我尝试了来自官方网站的文档,但这不起作用.仅供参考,我在Windows平台上.
I tried the docs from official site, but that's not working. FYI I am on windows platform.
推荐答案
在项目中创建一个JNI文件夹,并为每种架构(arm,armv7,x86等)添加一个文件夹.将相应的libcurl.so文件放置在相应的文件夹中.由于这是重建的共享二进制文件,因此需要将其添加到Android.mk文件中
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)
创建一个使用Curl中的库的JNI C文件,并从Java源代码中调用本机代码.
Create a JNI C file that uses the libraries from Curl and call the native code from Java source.
static {
System.loadLibrary("curl");
}
如果您使用的是Windows平台,则不应有所作为.在所有平台上,将开源liv文件添加到Android NDK的过程几乎相同.
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.
这篇关于如何在本地android项目中集成libcurl并在Windows上使用ndk进行构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!