How to speed up cocos2d-x build with prebuilt lib

How to speed up cocos2d-x build with prebuilt lib


Could be because of the debug symbols


It’s very useful, thanks!


I just did a real test between a full build, and a build using prebuilt cocos libs.
For the record, I am using the libs build in the full build (just copied to the prebuilt folder) for my prebuilt build.
This means that both builds use the exact same cocos .a files.

My game so is 2.73 MB for the full build, and 10.0 MB for the prebuilt build.
My APK package is 6.52 MB for the full build, and 9.48 MB for the prebuilt build (made with Eclipse).

EDIT: Some buildinfo, I’m only building armeabi-v7a and with these APP_CPPFLAGS:



for us it is :slight_smile: we have like 10+ projects and not all of them have same core cocos2d-x, some have changes in it. So it will be hard to maintain… like add changes compile, remove changes compile… in root folder, will be easier if I can specify cocos2d generated folder for each project set and compile it. Also generated folder is much smaller in size like 300mb against 1gb of downloaded root.

Also would be nice to have option to specify which language to compile, rigth now seems only due this it not compiling generated cocos2d folder, it trying to search for LUA and JS files, but we need only C++ precompiled libs.


My APK package is 6.52 MB for the full build, and 9.48 MB for the prebuilt build (made with Eclipse).

Are you sure that with Eclipse you compiled release apk? If not n release mode you can save extra 2mb±


I’m building my game with “python -b release”, is that what you mean?
In eclipse I just do a refresh, clean and then an export…


yes, that one.

with cocos console it looks like

cocos compile -p android -j 10 -m release

For eclipse I think it not using release flag by default, depends on config.
in default config it checking if statement if it is release or debug build, but you can remove that if.

Make sure that this options are:

APP_OPTIM := release


I highly applaud this. Can we still use SDKBOX without problem, as loose source files next to the precompiled cocos2d-x lib? Just want to make sure.

I am trying this out for iOS. But I just get ‘cocos2d.h’ file not found :frowning: I did define COCOS2DX_ROOT like this

export COCOS2DX_ROOT=/Users/umai/cocos2d-x-3.8.1

Update: I think I fixed it. In the project itself, I added a User-Defined Build setting COCOS2DX_ROOT with the path specified. Then in Header Search paths all the paths should begin with $(COCOS2DX_ROOT) just like in OP’s post. Took me an hour to figure out… doh.

The template app launched and seems to work fine. Hoooray.


Did you get is solved?


Yes things work great so far.

For iOS, why not compile into a .framework instead of a lib? The header files can be included in the framework, so no hassle with environmental variables and everything will be really tidy.


Anyone see this issue with the prebuilt when compiling for android.

Build Log:

[armeabi] SharedLibrary :
vtable for Character: error: undefined reference to ‘non-virtual thunk to cocos2d::Sprite::getTexture() const’
vtable for Character: error: undefined reference to ‘non-virtual thunk to cocos2d::Sprite::setTexture(cocos2d::Texture2D*)’

…/…/…/cocos2d-x/cocos/prebuilt-mk/./…/…/prebuilt/android/armeabi/libcocos2dxinternal.a(CCSprite.o):vtable for cocos2d::Sprite: warning: relocation refers to discarded section

…/…/…/cocos2d-x/cocos/prebuilt-mk/./…/…/prebuilt/android/armeabi/libcocos2dxinternal.a(CCSprite.o):vtable for cocos2d::Sprite: warning: relocation refers to discarded section

collect2: error: ld returned 1 exit status

Edit: just FYI I solved my run issues due to the change in main.cpp interface that I must’ve regressed during some commit in the past couple weeks.


I am not sure why the .lib over a .framework. Create an issue for that here:

and someone will at least tell you why the decision was made and perhaps your feedback will have them change to a .framework even.


Maybe I will suggest it.

On another note, I got some problem with iOS; it won’t recognize CC_DLL when making bridging calls to ObjC code, like this:

void CC_DLL IOSBRIDGE_DOSOMETHING(std::string somestring);

Error is

*Expected ; after top level declaration.

That seems random, just because it cannot find a definition of CC_DLL. Either I did something wrong, I just copied some working code from a previous project that ran c2d-x 3.5, 3.6 or something, or there is a problem with the header includes, or the library :stuck_out_tongue:


Fixed it. I probably made some mistake somewhere, but adding #include "platform/CCPlatformMacros.h" fixed my problem.


after successfull build cocos i try to build my project and here is error output:

make: Entering directory `/brr_client_cpp/'
/brr_client_cpp/ *** missing separator.  Stop.
make: Leaving directory `/brr_ios/brr_client_cpp/'
Error running command, return code: 2.

i dont use Box2d why it is trying to use it?
cocos2dx 3.8.1



For Android I did all steps, but when I run “cocos deploy …” coco2d engine is recompiled.



Does it only happens for cocos deploy or on cocos compile as well?


Both cocos compile and deploy. How about you? Did you check cocos compile?


It’s sad that there is no way to make this work on WP… I hope that this will change in time.


Any progress for WP?