I’m a beginner of cocos2dx. When I was setting the project with cygwin, I faced the following error. I have no idea why it happened. May anyone help me?
$ ./build_native.sh
NDK_ROOT = /cygdrive/C/androidpackage/android-ndk-r9
COCOS2DX_ROOT = /cygdrive/c/cocos2d-x-2.1.4/testing/proj.android/…/…
APP_ROOT = /cygdrive/c/cocos2d-x-2.1.4/testing/proj.android/…
APP_ANDROID_ROOT = /cygdrive/c/cocos2d-x-2.1.4/testing/proj.android
Using prebuilt externals
Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml
Android NDK: WARNING:/cygdrive/c/cocos2d-x-2.1.4/testing/proj.android/…/…/cocos2dx/Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignored for static libra ries
make: Entering directory `/cygdrive/c/cocos2d-x-2.1.4/testing/proj.android’
Compile++ thumb : cocos2dx_static <= CCCommon.cpp
C:/cocos2d-x-2.1.4/testing/proj.android/…/…/cocos2dx/platform/android/CCCommon.cpp: In function ‘void cocos2d::CCLog(char const**, …)’:
C:/cocos2d-x-2.1.4/testing/proj.android/…/…/cocos2dx/platform/android/CCCommon.cpp:44:72: error: format not a string literal and no format arguments
C:/cocos2d-x-2.1.4/testing/proj.android/…/…/cocos2dx/platform/android/CCCommon.cpp: In function ’void cocos2d::CCLuaLog’:
C:/cocos2d-x-2.1.4/testing/proj.android/…/…/cocos2dx/platform/android/CCCommon.cpp:54:77: error: format not a string literal and no format arguments
cc1plus.exe: some warnings being treated as errors
/cygdrive/C/androidpackage/android-ndk-r9/build/core/build-binary.mk:348: recipe for target `obj/local/armeabi/objs/cocos2dx_static/platform/android/CCCommon.o’ failed
make:**** [obj/local/armeabi/objs/cocos2dx_static/platform/android/CCCommon.o] Error 1
make: Leaving directory `/cygdrive/c/cocos2d-x-2.1.4/testing/proj.android’
[dongsong@localhost proj.android]$ ./build_native.sh
NDK_ROOT = /data/android/android-ndk-r9
COCOS2DX_ROOT = /data/android/cocos2d-x-2.1.4/HelloWorld/proj.android/../..
APP_ROOT = /data/android/cocos2d-x-2.1.4/HelloWorld/proj.android/..
APP_ANDROID_ROOT = /data/android/cocos2d-x-2.1.4/HelloWorld/proj.android
Using prebuilt externals
Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml
Android NDK: WARNING:/data/android/cocos2d-x-2.1.4/HelloWorld/proj.android/../../cocos2dx/Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignored for static libraries
make: Entering directory `/data/android/cocos2d-x-2.1.4/HelloWorld/proj.android'
Compile++ thumb : game_shared <= main.cpp
Compile++ thumb : game_shared <= AppDelegate.cpp
Compile++ thumb : game_shared <= HelloWorldScene.cpp
...
Compile++ thumb : cocos2dx_static <= CCCommon.cpp
/data/android/cocos2d-x-2.1.4/HelloWorld/proj.android/../../cocos2dx/platform/android/CCCommon.cpp: In function 'void cocos2d::CCLog(char const*, ...)':
/data/android/cocos2d-x-2.1.4/HelloWorld/proj.android/../../cocos2dx/platform/android/CCCommon.cpp:44:72: error: format not a string literal and no format arguments [-Werror=format-security]
/data/android/cocos2d-x-2.1.4/HelloWorld/proj.android/../../cocos2dx/platform/android/CCCommon.cpp: In function 'void cocos2d::CCLuaLog(char const*)':
/data/android/cocos2d-x-2.1.4/HelloWorld/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
make: *** [obj/local/armeabi/objs/cocos2dx_static/platform/android/CCCommon.o] Error 1
make: Leaving directory `/data/android/cocos2d-x-2.1.4/HelloWorld/proj.android'
Oops. I have had to delete my previous message due to stupid mistake.
So, to workaround this problem you should add -Wformat=0 to APP_CPPFLAGS in Application.mk
However, I believe the proper fix of this problem is to take those warnings into account and bring the code to a proper state.
I met similar question with environment ADT-Eclipse, andriod_ndk_9, when I compiling example project “HelloCpp” in cocos2d-x 2.1.5. There are only those warning info, but if I ignore it and run the application, can only show black screen without any info.
And I can compile and run it under visual studio dev environment. I config it by
*`` *** Build of configuration Default for project HelloCpp ****
‘d:\android-ndk-r9/ndk-build’ -C /cygdrive/c/cocos2d-x-2.1.5/samples/Cpp/HelloCpp/proj.android NDK_MODULE_PATH=/cygdrive/c/cocos2d-x-2.1.5/samples/Cpp/HelloCpp/proj.android/…/…/…/…:/cygdrive/c/cocos2d-x-2.1.5/samples/Cpp/HelloCpp/proj.android/…/…/…/…/cocos2dx/platform/third_party/android/prebuilt
Android NDK: WARNING:/cygdrive/c/cocos2d-x-2.1.5/samples/Cpp/HelloCpp/proj.android/…/…/…/…/cocos2dx/Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignored for static libraries
make: Entering directory `/cygdrive/c/cocos2d-x-2.1.5/samples/Cpp/HelloCpp/proj.android’
Cygwin : Generating dependency file converter script
Compile++ thumb : hellocpp_shared <= main.cpp
Compile++ thumb : hellocpp_shared <= AppDelegate.cpp
…
C:/cocos2d-x-2.1.5/samples/Cpp/HelloCpp/proj.android/…/…/…/…/cocos2dx/kazmath/src/quaternion.c: In function ‘kmQuaternionAssign’:
C:/cocos2d-x-2.1.5/samples/Cpp/HelloCpp/proj.android/…/…/…/…/cocos2dx/kazmath/src/quaternion.c:478:5: warning: incompatible implicit declaration of built-in function ‘memcpy’ [enabled by default]
C:/cocos2d-x-2.1.5/samples/Cpp/HelloCpp/proj.android/…/…/…/…/cocos2dx/kazmath/src/vec4.c: In function ‘kmVec4Assign’:
C:/cocos2d-x-2.1.5/samples/Cpp/HelloCpp/proj.android/…/…/…/…/cocos2dx/kazmath/src/vec4.c:150:5: warning: incompatible implicit declaration of built-in function ‘memcpy’ [enabled by default]
It’s caused by android-ndk-r9, you could delete -Werror=format-security from android-ndk-r9/build/core/default-build-commands.mk
It’s not NDK, it’s Cocos2dx. Those errors/warnings are not an empty sound, they are important. The only correct solution is too fix the errors, not to make the compiler shut up.
Red Zhen wrote:
> It’s caused by android-ndk-r9, you could delete Werror=format-security from android-ndk-r9/build/core/default-build-commands.mk
>
It’s not NDK, it’s Cocos2dx. Those errors/warnings are not an empty sound, they are important. The only correct solution is too fix the errors, not to make the compiler shut up.
it’s ndk,i’m deleteWerror=format-security compiler passed