[Cocos2d-x 3.14-1][Android]fatal error: curl/curl.h: No such file or directory

[Cocos2d-x 3.14-1][Android]fatal error: curl/curl.h: No such file or directory
0.0 0

#1

Hi,

I feel really stupid for asking this…
I went through the whole site searching for how to add curl to my proj.android and still don’t get it ;(

I’m compiling using:
C:\Tmp\MyCurl\proj.android>cocos compile -p android -ap android-25

And get:
jni/…/…/Classes/HelloWorldScene.cpp:9:23: fatal error: curl/curl.h: No such file or directory
#include "curl/curl.h

I guess I have to add ‘something’ to jni/Android.mk…

What I tried:

  • looking at cpp-test example: there is no mention of curl in Android.mk… I know it works, but as to why - magic…
  • adding $(call import-module,curl/prebuilt/android)

Can someone explain what is the proper way of adding curl (and I guess other libraries) to Android.mk? That is include files and libraries.

Is there some documentation on how to do this? I guess this is basic stuff and a wiki wouldn’t hurt.

I’m willing to do a write-up for other poor souls.


#2

Eureka!

So to include the header files edit jni/Android.mk this way:

before:
LOCAL_C_INCLUDES := $(LOCAL_PATH)/…/…/Classes

after:
LOCAL_C_INCLUDES := $(LOCAL_PATH)/…/…/Classes
$(LOCAL_PATH)/…/…/cocos2d/external/curl/include/android

And for the libraries (two steps):

before:
LOCAL_STATIC_LIBRARIES := cocos2dx_static

after:
LOCAL_STATIC_LIBRARIES := cocos2dx_static
LOCAL_STATIC_LIBRARIES += cocos_curl_static

AND

before:
# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END

after:
# _COCOS_LIB_IMPORT_ANDROID_BEGIN
$(call import-module,curl/prebuilt/android)
# _COCOS_LIB_IMPORT_ANDROID_END

Had to read http://android.mk/ first :wink:

Please comment, if there’s a better way.