Cocos2d-x Plugin-X error: format not a string literal and no format arguments

 Cocos2d-x-3.0alpha1 플러그인 빌드중 protocols 부분에서 string 관련 컴파일 에러가 발생했습니다. NDK는  android-ndk-r9b 환경입니다.


Now publish protocols
---------------------------------
target dir is /cygdrive/d/cocos2d-x-3.0alpha1/plugin/publish/protocols
android project dir is /cygdrive/d/cocos2d-x-3.0alpha1/plugin/protocols/proj.and
roid

Publish plugin for android
/cygdrive/d/cocos2d-x-3.0alpha1/plugin/protocols/proj.android /cygdrive/d/cocos2
d-x-3.0alpha1/plugin/tools /cygdrive/d/cocos2d-x-3.0alpha1/plugin/tools
   [subant] No sub-builds to iterate on

BUILD SUCCESSFUL
Total time: 0 seconds
   [subant] No sub-builds to iterate on

BUILD SUCCESSFUL
Total time: 3 seconds
Build C++ code
/cygdrive/d/cocos2d-x-3.0alpha1/plugin/tools/toolsForPublish /cygdrive/d/cocos2d
-x-3.0alpha1/plugin/protocols/proj.android /cygdrive/d/cocos2d-x-3.0alpha1/plugi
n/tools /cygdrive/d/cocos2d-x-3.0alpha1/plugin/tools

/cygdrive/d/cocos2d-x-3.0alpha1/plugin/protocols/proj.android /cygdrive/d/cocos2
d-x-3.0alpha1/plugin/tools /cygdrive/d/cocos2d-x-3.0alpha1/plugin/tools
make: Entering directory '/cygdrive/d/cocos2d-x-3.0alpha1/plugin/protocols/proj.
android'
Android NDK: WARNING: APP_PLATFORM android-9 is larger than android:minSdkVersio
n 7 in ./AndroidManifest.xml
Android NDK: WARNING:jni/Android.mk:PluginProtocolStatic: LOCAL_LDLIBS is always
 ignored for static libraries
Android NDK: WARNING:jni/Android.mk:PluginProtocolStatic: LOCAL_LDLIBS is always
 ignored for static libraries
[armeabi] Compile++ thumb: PluginProtocolStatic <= PluginUtils.cpp
jni/../../platform/android/PluginUtils.cpp: In static member function 'static vo
id cocos2d::plugin::PluginUtils::outputLog(char const*, char const*, ...)':
jni/../../platform/android/PluginUtils.cpp:172:53: error: format not a string li
teral and no format arguments [-Werror=format-security]
cc1plus.exe: some warnings being treated as errors

/cygdrive/d/android/android-ndk-r9b/build/core/build-binary.mk:386: recipe for t
arget 'obj/local/armeabi/objs/PluginProtocolStatic/__/__/platform/android/Plugin
Utils.o' failed
make: *** [obj/local/armeabi/objs/PluginProtocolStatic/__/__/platform/android/Pl
uginUtils.o] Error 1
make: Leaving directory '/cygdrive/d/cocos2d-x-3.0alpha1/plugin/protocols/proj.a
ndroid'


Native build action success.
/cygdrive/d/cocos2d-x-3.0alpha1/plugin/tools /cygdrive/d/cocos2d-x-3.0alpha1/plu
gin/tools

error: format not a string literal and no format arguments [-Werror=format-security] 라는 에러인데 cocos2d-x-3.0alpha1\plugin\protocols\proj.android\jni\Application.mk 파일을 수정해야합니다.

APP_CPPFLAGS += -frtti

이렇게 되어 있는데 아래와 같이 붉은색 부분을 추가후 ./publish.sh 해줍니다.

APP_CPPFLAGS += -frtti -Wno-error=format-security

 그러면 일단 경고는 발생하지만 컴파일이 잘 됩니다.


Total time: 2 seconds
Build C++ code
/cygdrive/d/cocos2d-x-3.0alpha1/plugin/tools/toolsForPublish /cygdrive/d/cocos2d
-x-3.0alpha1/plugin/protocols/proj.android /cygdrive/d/cocos2d-x-3.0alpha1/plugi
n/tools /cygdrive/d/cocos2d-x-3.0alpha1/plugin/tools

/cygdrive/d/cocos2d-x-3.0alpha1/plugin/protocols/proj.android /cygdrive/d/cocos2
d-x-3.0alpha1/plugin/tools /cygdrive/d/cocos2d-x-3.0alpha1/plugin/tools
make: Entering directory '/cygdrive/d/cocos2d-x-3.0alpha1/plugin/protocols/proj.
android'
Android NDK: WARNING: APP_PLATFORM android-9 is larger than android:minSdkVersio
n 7 in ./AndroidManifest.xml
Android NDK: WARNING:jni/Android.mk:PluginProtocolStatic: LOCAL_LDLIBS is always
 ignored for static libraries
Android NDK: WARNING:jni/Android.mk:PluginProtocolStatic: LOCAL_LDLIBS is always
 ignored for static libraries
[armeabi] Compile++ thumb: PluginProtocolStatic <= PluginFactory.cpp
[armeabi] Compile++ thumb: PluginProtocolStatic <= PluginJniHelper.cpp
[armeabi] Compile++ thumb: PluginProtocolStatic <= PluginUtils.cpp
jni/../../platform/android/PluginUtils.cpp: In static member function 'static vo
id cocos2d::plugin::PluginUtils::outputLog(char const*, char const*, ...)':
jni/../../platform/android/PluginUtils.cpp:172:53: warning: format not a string
literal and no format arguments [-Wformat-security]
[armeabi] Compile++ thumb: PluginProtocolStatic <= PluginProtocol.cpp
[armeabi] Compile++ thumb: PluginProtocolStatic <= ProtocolAnalytics.cpp
[armeabi] Compile++ thumb: PluginProtocolStatic <= ProtocolIAP.cpp
[armeabi] Compile++ thumb: PluginProtocolStatic <= ProtocolAds.cpp
[armeabi] Compile++ thumb: PluginProtocolStatic <= ProtocolShare.cpp
[armeabi] Compile++ thumb: PluginProtocolStatic <= ProtocolUser.cpp
[armeabi] Compile++ thumb: PluginProtocolStatic <= ProtocolSocial.cpp
[armeabi] Compile++ thumb: PluginProtocolStatic <= PluginManager.cpp
[armeabi] Compile++ thumb: PluginProtocolStatic <= PluginParam.cpp
[armeabi] StaticLibrary  : libPluginProtocolStatic.a
[armeabi] Compile thumb  : android_native_app_glue <= android_native_app_glue.c
[armeabi] StaticLibrary  : libandroid_native_app_glue.a
[armeabi-v7a] Compile++ thumb: PluginProtocolStatic <= PluginFactory.cpp
[armeabi-v7a] Compile++ thumb: PluginProtocolStatic <= PluginJniHelper.cpp
[armeabi-v7a] Compile++ thumb: PluginProtocolStatic <= PluginUtils.cpp
jni/../../platform/android/PluginUtils.cpp: In static member function 'static vo
id cocos2d::plugin::PluginUtils::outputLog(char const*, char const*, ...)':
jni/../../platform/android/PluginUtils.cpp:172:53: warning: format not a string
literal and no format arguments [-Wformat-security]
[armeabi-v7a] Compile++ thumb: PluginProtocolStatic <= PluginProtocol.cpp
[armeabi-v7a] Compile++ thumb: PluginProtocolStatic <= ProtocolAnalytics.cpp
[armeabi-v7a] Compile++ thumb: PluginProtocolStatic <= ProtocolIAP.cpp
[armeabi-v7a] Compile++ thumb: PluginProtocolStatic <= ProtocolAds.cpp
[armeabi-v7a] Compile++ thumb: PluginProtocolStatic <= ProtocolShare.cpp
[armeabi-v7a] Compile++ thumb: PluginProtocolStatic <= ProtocolUser.cpp
[armeabi-v7a] Compile++ thumb: PluginProtocolStatic <= ProtocolSocial.cpp
[armeabi-v7a] Compile++ thumb: PluginProtocolStatic <= PluginManager.cpp
[armeabi-v7a] Compile++ thumb: PluginProtocolStatic <= PluginParam.cpp
[armeabi-v7a] StaticLibrary  : libPluginProtocolStatic.a
[armeabi-v7a] Compile thumb  : android_native_app_glue <= android_native_app_glu
e.c
[armeabi-v7a] StaticLibrary  : libandroid_native_app_glue.a
make: Leaving directory '/cygdrive/d/cocos2d-x-3.0alpha1/plugin/protocols/proj.a
ndroid'


Native build action success.
/cygdrive/d/cocos2d-x-3.0alpha1/plugin/tools /cygdrive/d/cocos2d-x-3.0alpha1/plu
gin/tools

 plugin\publish\protocols\android\lib\armeabi-v7a 과 plugin\publish\protocols\android\lib\armeabi 폴더에 각각 libPluginProtocolStatic.a 파일이 생성되었으면 성공한 것입니다.

이 블로그의 인기 게시물

CMake Windows에 설치하기

Unity3D 안드로이드 Keystore 생성하기

Unity3D iOS Plugin 만들어 연동하기