Link own shared library

Link own shared library
0.0 0


I’m using cocos2d-x project and I want to link my own shared library to it.

That library is built with same config as cocos2d-x (ndk version, etc.).

In of the project there is line:

LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static cocos_extension_static

And in ROOT/obj/local/armeabi there are all these static libraries: libcocos2d.a, libextensions.a, …

I just copy my so-library into /obj/local/armeabi of the project, and add into mk: LOCAL_LDLIBS += -lThe2D and it fails to find such library. I know that I can specify search path but, I think, this is wrong way. There should be some place I can link own libraries. Any suggestions?
I’ve found how to link it in ugly way:

LOCAL_LDLIBS += -L$(LOCAL_PATH)/../obj/local/armeabi -lThe2D

No linker error, but when eclipse builds the project and runs it, my library isn’t copied into install path. Only these one:
Install : => libs/armeabi/
Install : => libs/armeabi/

And application crashes on device because it can’t find the library (The2D).


I use two different Cocos2d-x projects with a pair of files.

I use LOCAL_WHOLE_STATIC_LIBRARIES to import the library into the game.


It’s no problem to build project without linker errors for now, but eclipse won’t copy my shared library into apk and application crashes because it can’t find and load this uncopied lib.


Okay, if someone would be interesting in future, I found the answer:
use ndk’s static/shared prebuilt future.


Hi Max,

Would be great if you provide the detailed steps.



Sure, all the steps are described here: with examples.