Still cannot understand how to link my cocos2d c++ project against 3rd party libs (static or shared)

Hi to all

Android Ndk and in Android programming is not in my primary competence, so I have to ask.
I have a cocos2d-x C++ based game which runs smoothly on Windows. Now I want to build it for Android. The problem is that I use external static libraries (*.lib in windows) files, which need to be linked in executable. I successfully built those libraries for android. Now I have shared *.so file and *.a files for different archs (see below). So far so good.
But after long researches, tries & errors, and still cannot understand how to link my cocos2d project against upper mentioned libs (static or shared).
Let me show you some screen shots.

This is my build of svgren lib as single shared library for different archs:

This is my build of svgren lib as separated static libs (dependencies) for different archs:

This is how my project look in android studio. Includes for the libs are not shown.

As a result configuration compile tasks completed successfully, but during linking process I got unresolved references, of course.

Thanks

Can you paste all your unresolved references in detail.

Can you run cocos new ... and does that build in Android Studio cleanly for you?

@netanalyzer In the screenshot you posted, there’s absolutely no trace of your libraries in Android.mk, so when building, the linker doesn’t even know that you want to link those 3rd party libraries.

There are plenty of examples on how to do this, even on this forum, such as here.

Android documentation has a page on it: linking prebuilt libraries

Other than that, I strongly recommend you stop using the Android.mk builds, and instead move to CMake builds, especially since going forward, CMake will be the only method used in Cocos2d-x (according to this).

1 Like

Finally I found the way to build apk :slight_smile:
(I had no time to deploy and test it on a device, even emulator. May be today after work if I have free time)

Here is what I did:

I have to create separate *.mk file for each static lib (modules), and include them in Android.mk:

Here is an content of cairo.mk

I also learnt that order of included *.mk files is very important.
I have to refine/refactor my project, still I’m happy that after 2 days I finally have success.

PS: I know that CMake builds will be only method in future, but I choose ndk-build because cmake build failed for me even with a newly created project with cocos new .... I use Cocos2d-x 3.17.1. My build machine OS is Windows 10. I do not remember the exact errors with cmake build, but this is another topic.