Cocos2d-x无法使用./build_native.sh在MacO中编译C ++代码

时间:2013-11-03 06:48:46

标签: android c++ macos android-ndk cocos2d-x

我在MacOs Mavericks下使用android-ndk-r9b和cocos2d-x-2.1.4。我能够为cocos2d-x创建android应用程序,但是当我尝试使用./build_native.sh脚本编译C ++代码时,编译器会给我一些警告并最终失败。

这些警告是:

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

我想知道是否有人遇到类似的错误,如何解决它?

谢谢!

1 个答案:

答案 0 :(得分:0)

这里的问题(Cocos2DX 2.1.1)

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

您可以关闭编译器错误:

Application.mk中的

: APP_CFLAGS + = -Wno-error = format-security

或更好,解决字符串格式的问题,在4点的cocos代码中(如上面的链接所示):

1 - CCCommon.cpp - __android_log_print(ANDROID_LOG_DEBUG,“cocos2d-x debug info”,buf); - &GT; __android_log_print(ANDROID_LOG_DEBUG,“cocos2d-x调试信息”,“%s”,buf);

2 - SimpleAudioEngine.cpp - LOGD(deviceModel); - &GT; LOGD( “%S”,deviceModel);

3 - OpenSLEngine.cpp - LOGD(errorInfo); - &GT; LOGD( “%S”,errorInfo中);

4 - SimpleAudioEngineOpenSL.cpp - LOGD(errorInfo); - &GT; LOGD( “%S”,errorInfo中);