Help! Curl help

gyls

Platinian
Original poster
Aug 6, 2022
15
3
3
24
Russia
I need to integrate the curl library into an android project in order to send requests from under C ++

The whole problem is the integration of this library using android.mk

What I just did not try (spent more than 9 hours) and failed to integrate curl using android.mk

Important! cMake doesn't interest me. We need the implementation on android.mk

What I have:
compiled curl libraries for different ABIs (libcurl.a), include folder (.h files)

There are not many tutorials on google for integrating curl into an android project

How I did (android.mk):

C++:
include $(CLEAR_VARS)
LOCAL_MODULE := ssl
LOCAL_SRC_FILES := build/openssl/$(TARGET_ARCH_ABI)/lib/libssl.a
LOCAL_EXPORT_CFLAGS := build/openssl/$(TARGET_ARCH_ABI)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := crypto
LOCAL_SRC_FILES := build/openssl/$(TARGET_ARCH_ABI)/lib/libcrypto.a
LOCAL_EXPORT_CFLAGS := build/openssl/$(TARGET_ARCH_ABI)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := curl
LOCAL_SRC_FILES := build/curl/$(TARGET_ARCH_ABI)/lib/libcurl.a
LOCAL_EXPORT_CFLAGS := $(LOCAL_PATH)build/curl/$(TARGET_ARCH_ABI)/include/curl/
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_C_INCLUDES := build/openssl/$(TARGET_ARCH_ABI)/include \
    $(LOCAL_PATH)build/curl/$(TARGET_ARCH_ABI)/include
LOCAL_STATIC_LIBRARIES := libcurl libssl libcrypto
then flags, declaration LOCAL_MODULE (for SHARED_LIBRARY), SRC_FILES (only for LOCAL_MODULE), LOCAL_LDLIBS and at the end include $(BUILD_SHARED_LIBRARY)


But this was not successful. The build is going well. But if I add the
C++:
#include <curl/curl.h>
to the main native-lib.cpp file, then the project does not see this file. But if I specify the full path #include "../.../....." then the file is integrated

But the trouble is that .h files inside curl cannot include themselves. Solution: I need to make a relative path in each file, not an absolute one, and this is not productive at all

The whole problem boils down to the fact that it is not possible to take out .h files so that they can be accessed through <curl/curl.h>, and not by "absolute path"

If anyone has an example of curl integration based on android.mk, please share your android.mk file setup or tell me what I'm doing wrong
 

8BIT

Approved Modder
Approved Modder
Dec 29, 2019
265
17,774
1,193
Here is an example(I Think Its Likely The Same Author That You Yanked The Code From :pepe010:)

This is the repo that i used to compile openssl,curl,zlib

after that , i placed EVERYTHING INSIDE build dir in the AndroidCurlExample-master/app/src/main/jni/libs/(As Mentioned in The Last Part of The Example Repo)

Then I Had This
1.png


Added This APP_PLATFORM := 21 To Application.mk

Then
2.png


It Wrked!:pepe019:

A Few Other Tests
4.png

3.png


I've Not Tested These Though(In A Device).
 
Last edited:
  • Like
Reactions: gyls