error: format not a string literal and no format arguments [-Werror=format-security]


#1

This is the O/P , i m getting after build in console…

gamer:proj.android gamer$ ./build_native.sh
NDK_ROOT = /Users/gamer/Documents/android-ndk-r9
COCOS2DX_ROOT = /Users/gamer/Documents/cocos2d-x-2.1.4/sampleX/proj.android/…/…
APP_ROOT = /Users/gamer/Documents/cocos2d-x-2.1.4/sampleX/proj.android/…
APP_ANDROID_ROOT = /Users/gamer/Documents/cocos2d-x-2.1.4/sampleX/proj.android
Using prebuilt externals
Android NDK: WARNING:/Users/gamer/Documents/cocos2d-x-2.1.4/sampleX/proj.android/…/…/cocos2dx/Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignored for static libraries
make: Entering directory `/Users/gamer/Documents/cocos2d-x-2.1.4/sampleX/proj.android’
Compile*+ thumb : cocos2dx_static <= CCCommon.cpp
Compile*+ thumb : cocos2dx_static <= CCFileUtilsAndroid.cpp
/Users/gamer/Documents/cocos2d-x-2.1.4/sampleX/proj.android/…/…/cocos2dx/platform/android/CCFileUtilsAndroid.cpp: In member function ‘virtual unsigned char* cocos2d::CCFileUtilsAndroid::getFileData(char const**, char const**, long unsigned int**)’:
/Users/gamer/Documents/cocos2d-x-2.1.4/sampleX/proj.android/…/…/cocos2dx/platform/android/CCFileUtilsAndroid.cpp:156:9: error: format not a string literal and no format arguments
cc1plus: some warnings being treated as errors
make:**** [obj/local/armeabi/objs/cocos2dx_static/platform/android/CCFileUtilsAndroid.o] Error 1
make: Leaving directory `/Users/gamer/Documents/cocos2d-x-2.1.4/sampleX/proj.android’

Please help …. and refer any tutorial


#2

AFAIK version 2.1.4 of cocos is not compatible with ndk-r9. Safest way is to use the r8e version of android ndk.


#3

You can put this in your Application.mk to disable treating those warnings as errors:
APP_CFLAGS += -Wno-error=format-security

There are more solutions for the same problem in this thread: http://www.cocos2d-x.org/boards/6/topics/32437?r=33260#message-33260


#4

Thanks it was a great help…