Cocos2d-x不能使用./build_native.sh在MacOs中编译c++代码

时间:2022-08-11 02:40:00

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.

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

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!

谢谢!

1 个解决方案

#1


0  

Same problem here (Cocos2DX 2.1.1)

同样的问题(Cocos2DX 2。1)

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

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

You can shut down the compiler error:

你可以关闭编译错误:

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

在应用程序中。可: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):

或者更好地解决了字符串格式的问题,在cocos代码的4个点(正如您在上面的链接中看到的):

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);

1 - CCCommon。cpp - __android_log_print(ANDROID_LOG_DEBUG,“cocos2d-x调试信息”,buf);-> __android_log_print(ANDROID_LOG_DEBUG,“cocos2d-x调试信息”,“%s”,buf);

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

2 - SimpleAudioEngine。cpp - LOGD(deviceModel);- > LOGD(“% s”,deviceModel);

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

3 - OpenSLEngine。cpp - LOGD(errorInfo);- > LOGD(“% s”,errorInfo);

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

4 - SimpleAudioEngineOpenSL。cpp - LOGD(errorInfo);- > LOGD(“% s”,errorInfo);

#1


0  

Same problem here (Cocos2DX 2.1.1)

同样的问题(Cocos2DX 2。1)

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

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

You can shut down the compiler error:

你可以关闭编译错误:

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

在应用程序中。可: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):

或者更好地解决了字符串格式的问题,在cocos代码的4个点(正如您在上面的链接中看到的):

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);

1 - CCCommon。cpp - __android_log_print(ANDROID_LOG_DEBUG,“cocos2d-x调试信息”,buf);-> __android_log_print(ANDROID_LOG_DEBUG,“cocos2d-x调试信息”,“%s”,buf);

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

2 - SimpleAudioEngine。cpp - LOGD(deviceModel);- > LOGD(“% s”,deviceModel);

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

3 - OpenSLEngine。cpp - LOGD(errorInfo);- > LOGD(“% s”,errorInfo);

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

4 - SimpleAudioEngineOpenSL。cpp - LOGD(errorInfo);- > LOGD(“% s”,errorInfo);