How to speed up cocos2d-x build with prebuilt lib

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?

Nothing to report on this :smile: I don’t see Windows Phone support coming in the near future.

Is -p linux support planned ?

the same at my side

My Android.mk file is exactly the same as the as the example above but still got this error. Any clue on this?

>     > Running command: compile
>     > Building mode: debug
>     > Using Eclipse project : /Users/Andy/workspace/gamedev/projects/CppTest/proj.android
>     > Android platform not specified, searching a default one...
>     > running: '/Users/Andy/Library/Android/sdk/tools/android update project -t android-15 -p /Users/Andy/workspace/gamedev/projects/CppTest/proj.android'

>     > Updated project.properties
>     > Updated local.properties
>     > Updated file /Users/Andy/workspace/gamedev/projects/CppTest/proj.android/proguard-project.txt
>     > Building native...
>     > NDK build mode: debug
>     > NDK_TOOLCHAIN_VERSION: 4.9
>     > running: '/Users/Andy/SDKs/android-ndk-r10e/ndk-build -C /Users/Andy/workspace/gamedev/projects/CppTest/proj.android -j4 NDK_MODULE_PATH=/Users/Andy/workspace/gamedev/cocos2d-x-3.8.1:/Users/Andy/workspace/gamedev/cocos2d-x-3.8.1/cocos/prebuilt-mk:/Users/Andy/workspace/gamedev/cocos2d-x-3.8.1/cocos:/Users/Andy/workspace/gamedev/cocos2d-x-3.8.1/external NDK_TOOLCHAIN_VERSION=4.9 NDK_DEBUG=1'

>     > Android NDK: WARNING: APP_PLATFORM android-15 is larger than android:minSdkVersion 9 in ./AndroidManifest.xml    
>     > Android NDK: WARNING: Ignoring unknown import directory: jni/../../cocos2d/cocos/prebuilt-mk    
>     > make: Entering directory `/Users/Andy/workspace/gamedev/projects/CppTest/proj.android'
>     > /Users/Andy/workspace/gamedev/cocos2d-x-3.8.1/external/Box2D/prebuilt-mk/Android.mk:10: *** missing separator.  Stop.
>     > make: Leaving directory `/Users/Andy/workspace/gamedev/projects/CppTest/proj.android'
>     > Error running command, return code: 2.

[Solved]
Don’t know why but the 10th line in the external/Box2D/prebuilt-mk/Android.mk look like this

LOCAL_SRC_FILES := ../../../prebuilt/android/$(TARGET_ARCH_ABI)/libbox2d
.a

Changed to this and it worked.

LOCAL_SRC_FILES := ../../../prebuilt/android/$(TARGET_ARCH_ABI)/libbox2d.a \

`Just curious that is this a bug on the lib?