0

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.

Eshan
  • 113
  • 1
  • 2
  • 8
  • Sounds like a perfect candidate for the JavaCPP Presets: https://github.com/bytedeco/javacpp-presets/wiki/Create-New-Presets – Samuel Audet Aug 30 '14 at 06:33

2 Answers2

3

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.

G3M
  • 1,023
  • 8
  • 19
  • thanks for the reply. I am not able to generate libcurl.so file. I am successfully generating the static library using ndk, but when trying same for shared library it is failing. – Eshan Aug 20 '14 at 05:42
  • You can use the precompiled static library. Check this answer to find out how to link them http://stackoverflow.com/questions/5463518/android-ndk-link-using-a-pre-compiled-static-library – G3M Aug 20 '14 at 17:53
  • Sure! Can you please upvote the answer if it did solve your problem. Thanks – G3M Aug 21 '14 at 22:49
  • Hello, I am trying this approach, but without success. I am using it in C source via JNI, built by NDK 20.x and Androud 3.5.3 (and latest gradle). Please see my comments in https://stackoverflow.com/questions/33960385/how-to-download-a-file-from-http-using-c (failed attempt due to mentioned bugs in C code) and https://stackoverflow.com/questions/27092844/how-to-download-a-file-from-a-url-in-c-as-a-browser-would (my current attempt). – HX_unbanned Jan 14 '20 at 15:54
0

No idea about windows, but as to the linker magic, see the links in Integrating MuPDF as a library project (Android)

Community
  • 1
  • 1
18446744073709551615
  • 16,368
  • 4
  • 94
  • 127