Building cURL for Cocos2d-x Eclipse, something is missing for me

There is no problem in Xcode, but in Eclipse there is unfortunately.

I did this in Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := game

LOCAL_MODULE_FILENAME := libgame

LOCAL_SRC_FILES := helloworld/main.cpp …/…/Classes/AppDelegate.cpp …/…/Classes/HelloWorldScene.cpp …/…/Classes/GameplayLayer.cpp …/…/Classes/swimmerc.cpp …/…/Classes/pugixml.cpp

LOCAL_C_INCLUDES := …/…/libs/cocos2dx …/…/libs/cocos2dx/platform …/…/libs/cocos2dx/include …/…/libs/CocosDenshion/include $(LOCAL_PATH)/…/…/Classes/

LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static curl_static

include $(BUILD_SHARED_LIBRARY)
$(call import-module,cocos2dx)
$(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl)
$(call import-module,CocosDenshion/android)

I put the `curl` folder in Classes. I then included it in `GameplayLayer.cpp`.
No errors occur if I use

CURL curl;
CURLcode res;
But as soon as I put
curl = curl_easy_init;
I get an error,
make:
** [obj/local/armeabi/libgame.so] Error 1

Please help, I would gladly give one of my kidneys in exchange for getting this %&#@ to work.

I’m getting:

undefined reference to `curl_easy_init’

Any pointer is greatly appreciated.

Hello,

I want to try cURL (as I don’t know is that I want to use but anyway, should be work for you and me).

You say that you get no error on xCode, but I add the lib at reference or added directly on xCode, but I got errors as soon as I put

#include "curl.h"

Can you explain me how you do on xCode, and I will try to do it on Eclipse after.

Thanks

you should set “header search paths” and library search paths" for libcurl for your project “Build Settings”

`Damien, in Xcode just add the header files folder to the frameworks. Click on the project in the left panel then scroll down to frameworks and add the folder.

`小 苏,

I did this in Eclipse:

Go to project properties
C/C++ General
Paths and Symbols

Then added everything I could get my hands on everywhere. I included the libcurl folder in all ‘Include’, ‘Lobrary Paths’ and ‘Source Location’. I then added the three libcrul.a files under ‘Libraries’.

Still doesn’t work.

I added this line in Android.mk to make it work.

LOCAL_STATIC_LIBRARIES := curl_static_prebuilt

Of course in order to connect to the internet you will also need to edit AndroidManifest.mk and add this line:

That’s good that you succeeded to do it.
I hope to do it too.

For the moment I’m still in xcode :frowning: . I add the last version 7.26.0 and just rename the folder to “curl”.
I added it as a group in xcode and when I compile, I need openssl and more.
So I remove the example folder.

After, when I compile, I have a redefinition of the strut timeval.
As it’s already created in platform.h of cocos2-x I remove it, but I now have this error :

Expected * before *
Expected '=', ',', ';', 'asm' or '__attribute__' before 'Missing_definition_of_macro_sread'

Do you have an idea of what I make wrong ?

Thanks,
Damien

Let me see, drag/drop both ‘curl’ and ‘libraries’ folders into the ‘Frameworks’ folder. Don’t rename anything inside Xcode. Also click on the target, go to Build phases, and drag/drop all curl header files inside ‘Compile Sources’. Then just to make sure, click on the ‘Summary’ tab then scroll down and add ‘libcurl.a’ to the frameworks. Also have another ‘curl’ folder inside ‘Classes’ and don’t forget the ’#include “curl.h”.

Hum I was forgetting libcurl.a
As I was looking everywhere to find some clues, I find that cocos2d-x already give include and libcurl.a
I added the include in classes and the libcurl.a in frameworks, and you three lines compile very fine.
I will play with it now :wink:

And to don’t stop after that, I will try directly on Android.

As I’m not that familiar in android I hope it won’t be that hard.
I will follow your steps.

Thanks,
Damien

Resources on Cocos2d-x are very scarce on the web. But I have a gem for you - the tests project. This is how I solved my problem. Run the tests program and view how everything is programmed and you will become an expert in Cocos2d-x! :smiley:

So be sure to try that.

Regarding Android development, it’s not hard. Eclipse is crap compared to Xcode (or maybe it’s just me) but once get the setup complete it will feel as if you’re programming for iOS, no difference.

Sorry to answer that late.

I play a bit in iOS with libcrul and it’s exactly that I need.
So to continue to debug on both iOS and Android, I still try to compile on Android.

I do both of your thread, my android.mk are same (just some lines less) and I update my manifest.

But when I do “./build_native.sh” I still got errors.
The first one is :
jni/…/…/Classes/MenuScene.cpp:3:18: error: curl.h: No such file or directory

Do you have add something else, maybe something that you don’t tell as it’s an evidence.
I’m sorry to ask you for something maybe that simple, but I really don’t see what to do to success.

Thanks,
Damien

You need to also add all the curl files in the classes folder. Make sure there is a Classes folder and in it a curl folder and in it all the header files. Then make sure that on top of curl.h there is something like ‘#ifndef CURL_CURL_H
#define
CURL_CURL_H’ where the first curl is the folder and the second the file itself. Then in your code include curl/curl.h.

Oh so cool.
I was thinking the line :
$(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl)

was enough but add the curl folder with .h files did it.

I just have to change the :
#include “curl.h”
by :
#include “curl/curl.h”

but it’s still compiling on xCode without adding a define.
Thanks a lot, I will play with it now.

Kind Regards,
Damien

Just a last question dear Husam.

I don’t know your use of libcurl, but maybe you can help me with asynchronous download.
I make my question is this post :
http://www.cocos2d-x.org/boards/6/topics/3762?r=12915

I hope you can help me again.

Thanks,
Damien