How to speed up cocos2d-x build with prebuilt lib

Hello all,

I wanted to build my sample project with prebuilt libs.
I’m using cocos2dx 3.11.1, when i want to change the library path in Xcode i can only see below image with $(inherited).
Should i add paths manually…? or whether i’m doing wrong somewhere…?

Please help me out guys…

Yes add the paths manual. You need to add paths as part of your project and then your target. I only use the pre-builts now.

Thanks for reply.

I added library paths manually, but still getting error like ‘cocos2d.h’ file not found’.

And whether i need to add Target Dependencies??, but not getting any dependency to add.

You need to do it a bit differently, at least this is what I do.

First:


HEADER_SEARCH_PATHS contains this for me, adjust for your setup.

/Volumes/GitHub/cocos2d-x/ 
/Volumes/GitHub/cocos2d-x/cocos 
/Volumes/GitHub/cocos2d-x/cocos/base 
/Volumes/GitHub/cocos2d-x/cocos/physics 
/Volumes/GitHub/cocos2d-x/cocos/math 
/Volumes/GitHub/cocos2d-x/cocos/2d 
/Volumes/GitHub/cocos2d-x/cocos/ui 
/Volumes/GitHub/cocos2d-x/cocos/network 
/Volumes/GitHub/cocos2d-x/cocos/audio/include 
/Volumes/GitHub/cocos2d-x/cocos/editor-support 
/Volumes/GitHub/cocos2d-x/extensions 
/Volumes/GitHub/cocos2d-x/external 
/Volumes/GitHub/cocos2d-x/external/chipmunk/include/chipmunk

Second:


HEADER_SEARCH_PATHS contains this for me, adjust for your setup.

/Volumes/GitHub/cocos2d-x/cocos/platform/ios 
/Volumes/GitHub/cocos2d-x/cocos/platform/ios/Simulation 
$(inherited)

LIBRARY_SEARCH_PATHS contains this for me, adjust for your setup

/Volumes/GitHub/cocos2d-x/prebuilt/ios

Thanks slackmoehrle it works…

For android i’m trying to generate prebuilt libs i run the command “cocos gen-libs -p android”.
I’m using NDK android-ndk-r10c
But getting below error logs

[armeabi] StaticLibrary : libcocos2dandroid.a
[armeabi] StaticLibrary : libcpufeatures.a
[armeabi] SharedLibrary : libcocos2dlua.so
/Volumes/workspace/cocos2d-x-3.11.1/tools/simulator/frameworks/runtime-src/proj.android/…/…/…/…/…//tools/simulator/libsimulator/proj.android/…/lib/ProjectConfig/ProjectConfig.cpp:24: error: relocation overflow in R_ARM_THM_CALL
/Volumes/workspace/cocos2d-x-3.11.1/tools/simulator/frameworks/runtime-src/proj.android/…/…/…/…/…//tools/simulator/libsimulator/proj.android/…/lib/ProjectConfig/ProjectConfig.cpp:26: error: relocation overflow in R_ARM_THM_CALL
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libcocos2dlua.so] Error 1
make: Leaving directory `/Volumes/workspace/cocos2d-x-3.11.1/tools/simulator/frameworks/runtime-src/proj.android’
Error running command, return code: 2.
Error running command, return code: 14.

Please help me…

Hi…
This post help me to solve above problem:

Thanks

Has anybody tried to use the pre-built libs with Android Studio?

If Yes, then can you please post the steps to set it up?

thanks in advance!!

@nite

I interested to use prebuilt with Android Studio too.

FYI, I’m using prebuilt library with cocos2d-js v3.8.1 and working fine.

But now i would like to use prebuilt library with Android Studio and gradle to add third party library which only support integration with Gradle or Maven.

I run command
cocos compile -p android --android-studio

It generated an apk.

Then i import the proj.android into Android Studio.
Project built with error
AppDelegate not found

Is there any solution to make Android Studio work with prebuilt library? Its really save a lot time.

Thanks.

hi, I scanned through this, and it looks very promising! Just wondering when the windows example and functionality may be ready? Thanks!

You can create win32 pre-builts already.

cocos gen-libs -p win32

If you change headers and add/remove or invert fields orders you usually need rebuild, otherwise your game will misbehave and its very likely to crash.

You always need to re-build if you make changes.

1 Like

hi! I just try to prebuilt cocos2dx lib for ios but when I run on ios device using arm64, the project show a lot of error. I see that the lib did not build for arm64, so how can I use prebuild lib to release project ?

Are they part of your target to link against?

Have you managed to solve this? I have the same problem …

ld: warning: ignoring file /path/cocos2d-x-3.14/prebuilt/ios/libcocos2d iOS.a, missing required architecture arm64 in file /path/cocos2d-x-3.14/prebuilt/ios/libcocos2d iOS.a (2 slices)

using prebuild libs “spine” is not working. it was working fine before that.

what version of Cocos2d-x? From .zip on our website or GitHub repo?

coco2d-x 3.14.1. From Website

ok, I think if you use the v3 branch from GitHub this is fixed.

You would need to clone, submodule update, download-deps, re-compile pre-builts. I am in the process of writing docs to help with using pre-builts better and working through issues like what you are having. So let us work together to solve.

sure, i will do this.
make sure you document Android part very detailed as iOS is simple and easy to setup. But i am stuck in android studio setup :frowning:
i am following this Guide but having some issues that i mentioned in comments there.