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:

APP_CPPFLAGS := -frtti -fexceptions -std=c++11 -fsigned-char -Wno-extern-c-compat -DCC_USE_PHYSICS=0 -DCC_USE_3D_PHYSICS=0 -DCC_ENABLE_BULLET_INTEGRATION=0 -DCC_ENABLE_BOX2D_INTEGRATION=0 -DCC_ENABLE_CHIPMUNK_INTEGRATION=0 -DCC_USE_NAVMESH=0 -DCC_USE_TIFF=0 -DCC_USE_WEBP=0 -DCC_ENABLE_SCRIPT_BINDING=0

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.

@MFHSchoonbrood
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 build_native.py -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 Application.mk 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_CPPFLAGS += -DNDEBUG
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
export PATH=$COCOS2DX_ROOT:$PATH

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 : libgame.so
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*)’

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

…/proj.android/…/…/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: https://github.com/cocos2d/cocos2d-x/issues

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/proj.android'
/brr_client_cpp/proj.android/../cocos2d/external/Box2D/prebuilt-mk/Android.mk:10: *** missing separator.  Stop.
make: Leaving directory `/brr_ios/brr_client_cpp/proj.android'
Error running command, return code: 2.

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

Hi,

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

Regards,
B

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?