简体   繁体   中英

Cocos2d-x fails to compile C++ code in MacOs using ./build_native.sh

I'm using android-ndk-r9b and cocos2d-x-2.1.4 under MacOs Mavericks. I was able to create the android application for cocos2d-x, but when I tried to compile the C++ code using ./build_native.sh script, the compiler get me some warnings and at the end failed.

These warnings are:

Android NDK: WARNING: APP_PLATFORM android-18 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml    
Android NDK: WARNING:/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignored for static libraries    


[armeabi] Compile thumb  : cocos2dx_static <= quaternion.c
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/kazmath/src/quaternion.c: In function 'kmQuaternionAssign':
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/kazmath/src/quaternion.c:478:5: warning: incompatible implicit declaration of built-in function 'memcpy' [enabled by default]
[armeabi] Compile thumb  : cocos2dx_static <= vec4.c
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/kazmath/src/vec4.c: In function 'kmVec4Assign':
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/kazmath/src/vec4.c:150:5: warning: incompatible implicit declaration of built-in function 'memcpy' [enabled by default]

[armeabi] Compile++ thumb: cocos2dx_static <= CCCommon.cpp
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/platform/android/CCCommon.cpp: In function 'void cocos2d::CCLog(char const*, ...)':
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/platform/android/CCCommon.cpp:44:72: error: format not a string literal and no format arguments [-Werror=format-security]
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/platform/android/CCCommon.cpp: In function 'void cocos2d::CCLuaLog(char const*)':
/Developer/cocos2d-x-2.1.4/samplecocos2dxandroid/proj.android/../../cocos2dx/platform/android/CCCommon.cpp:54:77: error: format not a string literal and no format arguments [-Werror=format-security]
cc1plus: some warnings being treated as errors

I'm wondering if someone has encounter similar errors, how how to revolve it?

Thanks!

Same problem here (Cocos2DX 2.1.1)

http://www.cocos2d-x.org/forums/6/topics/32437?r=39742#message-39742

You can shut down the compiler error:

in Application.mk: APP_CFLAGS += -Wno-error=format-security

or better, solve the problem of string format, in 4 points of cocos code (as you can see in the link above):

1 - CCCommon.cpp - __android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", buf); -> __android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "%s", buf);

2 - SimpleAudioEngine.cpp - LOGD(deviceModel); -> LOGD("%s",deviceModel);

3 - OpenSLEngine.cpp - LOGD(errorInfo); -> LOGD("%s",errorInfo);

4 - SimpleAudioEngineOpenSL.cpp - LOGD(errorInfo); -> LOGD("%s",errorInfo);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM