Cocos 3.13.1 curl build issue

-cocos2d-x version: 3.13.1
-build tool : Android Stdio 2.2.3
-NDK version: r10c
-VS version: 2013
-targetSdkVersion 22

I built it with 3.13.1
In all functions that call ‘curl_easy_xxx’
An error occurred next.

jni/…/…/…/FTP_Update.cpp:1303: error: undefined reference to ‘curl_easy_setopt’
jni/…/…/…/FTP_Update.cpp:1304: error: undefined reference to ‘curl_easy_setopt’
jni/…/…/…/FTP_Update.cpp:1305: error: undefined reference to ‘curl_easy_setopt’
jni/…/…/…/FTP_Update.cpp:1308: error: undefined reference to ‘curl_easy_setopt’
jni/…/…/…/FTP_Update.cpp:1318: error: undefined reference to ‘curl_easy_perform’
jni/…/…/…/FTP_Update.cpp:1354: error: undefined reference to ‘curl_version_info’
jni/…/…/…/FTP_Update.cpp:1399: error: undefined reference to ‘curl_easy_perform’
jni/…/…/…/FTP_Update.cpp:1412: error: undefined reference to ‘curl_easy_getinfo’
jni/…/…/…/FTP_Update.cpp:1450: error: undefined reference to ‘curl_global_init’
jni/…/…/…/FTP_Update.cpp:1451: error: undefined reference to ‘curl_easy_init’
jni/…/…/…/FTP_Update.cpp:1470: error: undefined reference to ‘curl_easy_perform’
jni/…/…/…/FTP_Update.cpp:1482: error: undefined reference to ‘curl_easy_cleanup’
jni/…/…/…/FTP_Update.cpp:1484: error: undefined reference to ‘curl_global_cleanup’
jni/…/…/…/FTP_Update.cpp:1525: error: undefined reference to ‘curl_easy_strerror’

There was no problem with 3.10 builds.

[Application.mk]
APP_STL := gnustl_static
NDK_TOOLCHAIN_VERSION := 4.9

APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=gnu++11 -fsigned-char -fexceptions
APP_LDFLAGS := -latomic

APP_ABI := armeabi

APP_DEBUG := $(strip $(NDK_DEBUG))
ifeq ($(APP_DEBUG),1)
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
APP_OPTIM := debug
else
APP_CPPFLAGS += -DNDEBUG
APP_OPTIM := release
endif

APP_PLATFORM := android-9

[Android.mk]
LOCAL_PATH := $(call my-dir)
COCOS_PATH := $(LOCAL_PATH)/…/…/…/Lib/cocos2d-x-3.13.1
BREAKPAD_PATH := D:/Project_ArcaneMobile/client/trunk/source/Arcane/Lib/google-breakpad

include $(CLEAR_VARS)
LOCAL_MODULE := breakpad_client
LOCAL_SRC_FILES := $(BREAKPAD_PATH)/libbreakpad_client.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)

$(call import-add-path,$(COCOS_PATH))
$(call import-add-path,$(COCOS_PATH)/external)
$(call import-add-path,$(COCOS_PATH)/cocos)
$(call import-add-path,$(COCOS_PATH)/cocos/audio/include)

LOCAL_SHORT_COMMANDS := true
LOCAL_MODULE := arcane_gui
LOCAL_MODULE_FILENAME := libarcanegui

SOURCE_FILES := $(wildcard $(LOCAL_PATH)/…/…/…/gui/*.cpp)
LOCAL_SRC_FILES := $(SOURCE_FILES:$(LOCAL_PATH)/%=%)

LOCAL_C_INCLUDES := $(LOCAL_PATH)/…/…/…/…/Arcane
$(LOCAL_PATH)/…/…/…/…/Arcane/gui
$(LOCAL_PATH)/…/…/…/…/Arcane/2d
$(LOCAL_PATH)/…/…/…/…/…/resource
$(LOCAL_PATH)/…/…/…/…/…/resource/config_ui
$(LOCAL_PATH)/…/…/…/…/…/resource/configure
$(COCOS_PATH)/cocos
$(COCOS_PATH)/cocos/2d
$(COCOS_PATH)/cocos/3d
$(COCOS_PATH)
$(COCOS_PATH)/external
$(COCOS_PATH)/extensions
$(COCOS_PATH)/external/curl/include/android/curl
$(LOCAL_PATH)/…/…/…/…/Arcane/Classes
$(LOCAL_PATH)/…/…/…/…/Arcane/Lib/Common
$(LOCAL_PATH)/…/…/…/…/Arcane/Lib/NetMobile
$(LOCAL_PATH)/…/…/…/…/Arcane/Lib/TinyXML
$(LOCAL_PATH)/…/…/…/…/Arcane/Lib/iconv
$(BREAKPAD_PATH)/src/common/android/include
$(BREAKPAD_PATH)/src

LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_internal_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static
LOCAL_WHOLE_STATIC_LIBRARIES += breakpad_client
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_SHORT_COMMANDS := true
LOCAL_MODULE := arcane_2d
LOCAL_MODULE_FILENAME := libarcane2d
SOURCE_FILES := $(wildcard $(LOCAL_PATH)/…/…/…/2d/*.cpp)
LOCAL_SRC_FILES := $(SOURCE_FILES:$(LOCAL_PATH)/%=%)

LOCAL_C_INCLUDES := $(LOCAL_PATH)/…/…/…/…/Arcane
$(LOCAL_PATH)/…/…/…/…/Arcane/gui
$(LOCAL_PATH)/…/…/…/…/Arcane/2d
$(LOCAL_PATH)/…/…/…/…/…/resource
$(LOCAL_PATH)/…/…/…/…/…/resource/config_ui
$(LOCAL_PATH)/…/…/…/…/…/resource/configure
$(COCOS_PATH)/cocos
$(COCOS_PATH)/cocos/2d
$(COCOS_PATH)/cocos/3d
$(COCOS_PATH)
$(COCOS_PATH)/external
$(COCOS_PATH)/extensions
$(COCOS_PATH)/external/curl/include/android/curl
$(LOCAL_PATH)/…/…/…/…/Arcane/Classes
$(LOCAL_PATH)/…/…/…/…/Arcane/Lib/Common
$(LOCAL_PATH)/…/…/…/…/Arcane/Lib/NetMobile
$(LOCAL_PATH)/…/…/…/…/Arcane/Lib/TinyXML
$(LOCAL_PATH)/…/…/…/…/Arcane/Lib/iconv
$(BREAKPAD_PATH)/src/common/android/include
$(BREAKPAD_PATH)/src

LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_internal_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static
LOCAL_WHOLE_STATIC_LIBRARIES += breakpad_client
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := p
LOCAL_SHORT_COMMANDS := true
LOCAL_MODULE_FILENAME := libcocos2dcpp

LOCAL_CFLAGS += -fno-omit-frame-pointer
LOCAL_EXPORT_CFLAGS += -fno-omit-frame-pointer

SOURCE_FILES := $(wildcard $(LOCAL_PATH)/…/…/…/*.cpp)

LOCAL_SRC_FILES := hellocpp/main.cpp
…/…/…/Classes/AppDelegate.cpp
…/…/…/Classes/ILayer.cpp
…/…/…/Lib/NetMobile/NetSock.cpp
…/…/…/Lib/NetMobile/Network.cpp
…/…/…/Lib/NetMobile/PacketProcessor.cpp
…/…/…/Lib/Common/ar.cpp
…/…/…/Lib/Common/csv.cpp
…/…/…/Lib/Common/debug.cpp
…/…/…/Lib/Common/define.cpp
…/…/…/Lib/Common/file.cpp
…/…/…/Lib/Common/Language.cpp
…/…/…/Lib/Common/LogConsole.cpp
…/…/…/Lib/Common/path.cpp
…/…/…/Lib/Common/random.cpp
…/…/…/Lib/Common/scanner.cpp
…/…/…/Lib/Common/SmartPointer.cpp
…/…/…/Lib/Common/timer.cpp
…/…/…/Lib/Common/Util.cpp
…/…/…/Lib/Common/utilFile.cpp
…/…/…/Lib/Common/utilStr.cpp
…/…/…/Lib/Common/resources.cpp
…/…/…/Lib/Common/PtData.cpp
…/…/…/Lib/Common/ostrformat.cpp
…/…/…/Lib/TinyXML/tinyxml.cpp
…/…/…/Lib/TinyXML/tinystr.cpp
…/…/…/Lib/TinyXML/tinyxmlerror.cpp
…/…/…/Lib/TinyXML/tinyxmlparser.cpp
$(SOURCE_FILES:$(LOCAL_PATH)/%=%)

LOCAL_LDLIBS := -llog

LOCAL_C_INCLUDES := $(LOCAL_PATH)/…/…/…/Classes
$(LOCAL_PATH)/…/…/…/…/Arcane
$(LOCAL_PATH)/…/…/…/…/Arcane/gui
$(LOCAL_PATH)/…/…/…/…/Arcane/2d
$(COCOS_PATH)/cocos
$(COCOS_PATH)/cocos/2d
$(COCOS_PATH)/cocos/3d
$(COCOS_PATH)/external
$(COCOS_PATH)/extensions
$(COCOS_PATH)
$(COCOS_PATH)/cocos/editor-support
$(COCOS_PATH)/cocos/audio/include
$(COCOS_PATH)/cocos/network
$(COCOS_PATH)/external/chipmunk/include/chipmunk
$(COCOS_PATH)/external/curl/include/android/curl
$(COCOS_PATH)/external/websockets/include/android
$(COCOS_PATH)/external/win32-specific/zlib/include
$(LOCAL_PATH)/…/…/…/…/…/resource
$(LOCAL_PATH)/…/…/…/…/…/resource/config_ui
$(LOCAL_PATH)/…/…/…/…/…/resource/configure
$(LOCAL_PATH)/…/…/…/…/Arcane/Classes
$(LOCAL_PATH)/…/…/…/…/Arcane/Lib/Common
$(LOCAL_PATH)/…/…/…/…/Arcane/Lib/NetMobile
$(LOCAL_PATH)/…/…/…/…/Arcane/Lib/TinyXML
$(LOCAL_PATH)/…/…/…/…/Arcane/Lib/iconv
$(BREAKPAD_PATH)/src/common/android/include
$(BREAKPAD_PATH)/src

LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_internal_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static
LOCAL_WHOLE_STATIC_LIBRARIES += breakpad_client
LOCAL_WHOLE_STATIC_LIBRARIES += arcane_gui
LOCAL_WHOLE_STATIC_LIBRARIES += arcane_2d
include $(BUILD_SHARED_LIBRARY)

$(call import-module,extensions)
$(call import-module,.)
$(call import-module,external/curl/prebuilt/android)

How did you get Cocos2d-x? .zip from our website or clone from GitHub?

from cocos website

And
The curl build did not work in that state.
so,


I have downloaded the link above. And overwrite.

I solved the problem.
After downloading from Cocos site
Cocos2d-x-3.13.1 / cocos / Android.mk

Include $ (CLEAR_VARS)
LOCAL_MODULE: = cocos2dx_static
LOCAL_MODULE_FILENAME: = libcocos2d
LOCAL_STATIC_LIBRARIES: = CocoStudio_Static
LOCAL_STATIC_LIBRARIES + = CocosBuilder_Static
LOCAL_STATIC_LIBRARIES + = Cocos3D_Static
LOCAL_STATIC_LIBRARIES + = spine_static
LOCAL_STATIC_LIBRARIES + = cocos_network_static
LOCAL_STATIC_LIBRARIES + = audioengine_static
LOCAL_STATIC_LIBRARIES + = cocos_curl_static <- this
Include $ (BUILD_STATIC_LIBRARY)

I added the following.

But


The downloaded libcrypto.a, libcurl.a, and libssl.a files
It did not build.

Error: undefined reference to getpwuid_r "

There was a mistake.
It was a problem of api level.
Compatibility with other libraries is a problem.
Raising or lowering the api level caused problems elsewhere.

Finally, Android applied curl 7.48.0.
IOS was applied as 7.5.0.

I’ve faced in Cocos2d-x 3.13.1 cURL issue in Android platform.
How can I fix it?

proj.android-studio/…/cocos2d/external/curl/prebuilt/android/armeabi/libcurl.a(libcurl_la-netrc.o):netrc.c:function Curl_parsenetrc: error: undefined reference to ‘getpwuid_r’
proj.android-studio/…/cocos2d/external/curl/prebuilt/android/armeabi/libcurl.a(libcurl_la-curl_ntlm_wb.o):curl_ntlm_wb.c:function ntlm_wb_init: error: undefined reference to ‘getpwuid_r’
proj.android-studio/…/cocos2d/external/curl/prebuilt/android/armeabi/libcurl.a(libcurl_la-curl_ntlm_wb.o):curl_ntlm_wb.c:function ntlm_wb_init: error: undefined reference to ‘getpwuid_r’
proj.android-studio/…/cocos2d/cocos/./platform/CCFileUtils.cpp:277: error: undefined reference to ‘atof’
proj.android-studio/…/cocos2d/cocos/./platform/CCFileUtils.cpp:286: error: undefined reference to ‘atof’
proj.android-studio/…/cocos2d/cocos/./base/CCConsole.cpp:1224: error: undefined reference to ‘srand’
proj.android-studio/…/cocos2d/cocos/./base/CCConsole.cpp:1253: error: undefined reference to ‘srand’
proj.android-studio/…/cocos2d/cocos/./base/ccUtils.cpp:254: error: undefined reference to ‘atof’
proj.android-studio/…/cocos2d/cocos/./2d/CCActionTiledGrid.cpp:280: error: undefined reference to ‘srand’
collect2.exe: error: ld returned 1 exit status

This is an API level issue.
You may be able to resolve this by setting API level.
I can not change the API level in my case
For Android, I used the curl version of 7.48.