sns game , need network, can make use of curl in cocos2d-x ?

sns game , need network, can make use of curl in cocos2d-x ?
0.0 0


hi eveybody,
i need to process network in cocos2d-x, such as request data from server,
the server is maybe php stuff, so can i use curl in cocos2d-x to use network…?


You’re using C*+ so you can use any C*+ library. One thing to consider is making sure you know how to compile whatever library you use for whatever platform you wish to deploy to. So if you’re trying to use something like curl on, say the iPhone or Android, then you’ll have to get help from curl-related support forums on how you can compile it for iPhone or Android.

Here’s a hint for curl on iPhone, google: ‘compile curl iphone’

I’d love to help but I’ve only ever used curl for Windows, but the best thing I can do is guide you to the right direction.


hi Emmanuel B: , thank you so much !, i will be use curl to try at first time…


cocos2d-x has integrated libcurl. There is a CurlTest in tests.


ok, thank you, i am looking.


android nkd-build complains “error: curl.h: No such file or directory”.

I looked into cocos2dx/ and didn’t findcurl headers included:

                    $(LOCAL_PATH)/include \
                    $(LOCAL_PATH)/platform \
                    $(LOCAL_PATH)/platform/third_party/android/iconv \
                    $(LOCAL_PATH)/platform/third_party/android/libpng \
                    $(LOCAL_PATH)/platform/third_party/android/libxml2 \

should I add it here? or treat it as another module?


Because cocos2dx don’t use libcurl, so it don’t need to add the corresponding header.
You should treat it as anther module.
cocos2dx offers its header files and .so.
You should add the header path and library path in your application’s
You can refer tests, it uses libcurl.


In case anyone else is wondering, you can enable cURL for your android project by editing the PROJECT/Classes/ file and adding the path to the cURL headers like so:

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../cocos2dx \ $(LOCAL_PATH)/../../cocos2dx/platform \ $(LOCAL_PATH)/../../cocos2dx/include \ $(LOCAL_PATH)/../../cocos2dx/platform/third_party/android/curl/ \ $(LOCAL_PATH)/../../CocosDenshion/include \ $(LOCAL_PATH)/../../cocos2dx/lua_support

Make sure the LOCAL_LDLIBS definition below also contains the line
@ ~~L$/…/…/cocos2dx/platform/third_party/android/libraries/$)~~lcurl@