14

我正在开发 cocos2d-x-2.1.4 上的游戏,但是,当我尝试在 Android 上构建它时,它失败并出现错误:format not a string literal and no format arguments [-Werror=format-security] on文件 CCCommon.cpp

但是,当我检查进攻线时,完全没问题。当我使用 Visual Studio 和 XCode 为 WIN32 和 iOS 构建文件时,该文件也构建得很好并且总是很好。

错误日志如下:

C:/Development/External/cocos2d-2.1rc0-x-2.1.3/projects/Game_C2DX213/proj.android/../../..//cocos2dx/platform/android/CCCommon.cpp: In function 'void cocos2d::CCLog(char const*, ...)':
/cygdrive/c/eclipse/android-ndk-r9/build/core/build-binary.mk:348: recipe for target `obj/local/armeabi/objs/cocos2dx_static/platform/android/CCCommon.o' failed
C:/Development/External/cocos2d-2.1rc0-x-2.1.3/projects/Game_C2DX213/proj.android/../../..//cocos2dx/platform/android/CCCommon.cpp:44:72: error: format not a string literal and no format arguments [-Werror=format-security]
C:/Development/External/cocos2d-2.1rc0-x-2.1.3/projects/Game_C2DX213/proj.android/../../..//cocos2dx/platform/android/CCCommon.cpp: In function 'void cocos2d::CCLuaLog(char const*)':
make: Leaving directory `/cygdrive/c/Development/External/cocos2d-2.1rc0-x-2.1.3/projects/Game_C2DX213/proj.android'
C:/Development/External/cocos2d-2.1rc0-x-2.1.3/projects/Game_C2DX213/proj.android/../../..//cocos2dx/platform/android/CCCommon.cpp:54:77: error: format not a string literal and no format arguments [-Werror=format-security]
cc1plus.exe: some warnings being treated as errors
4

2 回答 2

24

注意cocos2d-x-2.1.4可能和ndk-r9不兼容,你有没有换过r8e试试?

您也可以将其放在 Application.mk 中以禁用将这些警告视为错误:APP_CFLAGS += -Wno-error=format-security

在这个线程中有更多相同问题的解决方案:

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

参考:http://www.cocos2d-x.org/boards/6/topics/33525?r=33579

于 2013-08-23T02:29:47.120 回答
13

您必须在 LOCAL_DISABLE_FORMAT_STRING_CHECKS := true 之后修改 Android.mk

于 2014-08-21T12:37:13.300 回答