1. Compile CCCommon. cpp
Prompt message:
[Armeabi] Compile ++ thumb: cocos2dx_static <= CCCommon. cpp
D:/cocos2D/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/samples/HelloCpp/proj. android /.. /.. /.. /cocos2dx/platform/android/CCCommon. cpp: In function 'void cocos2d: CCLog (char const *,...) ':
D:/cocos2D/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/samples/HelloCpp/proj. android /.. /.. /.. /cocos2dx/platform/android/CCCommon. cpp: 44: 72: error: format not a string literal and no format arguments [-Werror = format-security]
Cc1plus.exe: some warnings being treated as errors
Solution: Add jni/Application. mk
APP_CFLAGS + =-Wno-error = format-security
2. No error pointing to jni/**/main. cpp
Tip: make: *** No rule to make target 'jni/FX/main. cpp ', needed by 'obj/local/armeabi/objs-debug/FX_shared/FX/main. O '. Stop.
Solution: Local_SRC_PATH definition error in jni/Android. mk, the specific definition method can be viewed under the cocos2d-x, the built-in sample instance.
3. NDK only supports errors caused by a small number of C or C ++ Libraries
Tip: In file encoded ded from jni/FX/main. cpp: 1: 0:
Jni/FX/main. h: 7: 21: fatal error: windows. h: No such file or directory
Compilation terminated.
Solution: main. cpp writing error. Remove main. h.
4. main. cpp Error
Error message: [armeabi] Compile ++ thumb: FX_shared <= main. cpp
Jni/FX/main. cpp: 10: 14: error: expected initializer before '_ tWinMain'
Solution: modify main. cpp according to the instance provided by cocos2d.
5. main. cpp contains the header file that does not exist.
Message: [armeabi] Compile ++ thumb: FX_shared <= main. cpp
Jni/FX/main. cpp: 6: 29: fatal error: HelloWorldScene. h: No such file or directory
Compilation terminated.
Solution: remove the missing header file.
6. The Local_Src_Path definition in Android. mk is incorrect.
Message: [armeabi] Compile ++ thumb: FX_shared <= main. cpp
[Armeabi] Compile ++ thumb: FX_shared <= *. cpp
Arm-linux-androideabi-g00000000.exe: fatal error: cannot specify-o with-c,-S or-E with multiple files
Compilation terminated.
Solution: follow the correct method to write Local_SRC_PATH in Android. mk.
7. Box2D/Box2D. h No such file or directory
Tip: In file encoded ded from jni/.../../Classes/FX_PauseGameScene.h: 2: 0,
From jni/.../../Classes/FX_PauseGameScene.cpp: 1:
Jni/.../../Classes/FX_Global.h: 8: 25: fatal error: Box2D/Box2D. h: No such file or directory
Compilation terminated.
Solution: remove the included Box2D/Box2D. h header file. Or copy the Box2D directory under external to the Class folder of the project to be compiled. Or add
LOCAL_WHOLE_STATIC_LIBRARIES + = box2d_static
$ (Call import-module, external/Box2D)
8. SimpleAudioEngine: No such file or directory
Tip: In file encoded ded from jni/.../../Classes/FX_PauseGameScene.h: 2: 0,
From jni/.../../Classes/FX_PauseGameScene.cpp: 1:
Jni/.../../Classes/FX_Global.h: 8: 31: fatal error: SimpleAudioEngine. h: No such file or directory
Compilation terminated.
Solution: SimpleAudioEngine. cpp is included in CocosDenshion/android, so we need to add it to the import-module
LOCAL_WHOLE_STATIC_LIBRARIES + = cocosdenshion_static
$ (Call import-module, CocosDenshion/android)
9. The NDK_BOOT Definition Format in build_native.sh is incorrect.
Prompt message:
./Build_native.sh: line 32: NDK_ROOT: command not found
The NDK_ROOT path is defined, and there is no space between NDK_ROOT and equal sign
10. NDK's support for C is incorrect.
Message: [armeabi] Compile ++ thumb: FX_shared <= FX_StartGame.cpp
In file encoded ded from jni/.../../Classes/FX_StartGame.cpp: 1: 0:
Jni/.../../Classes/FX_StartGameScene.h: 25: 2: error: 'carray' does not name a type
Jni/.../../Classes/FX_StartGame.cpp: In member function 'bool FX_StartGameScene: addPipeSprite ()':
Jni/.../../Classes/FX_StartGame.cpp: 63: 2: error: 'paniframe' was not declared in this scope
Jni/.../../Classes/FX_StartGame.cpp: 69: 31: error: 'sprintf _ s' was not declared in this scope
/Cygdrive/D/android-ndk-r9d-windows-x86/android-ndk-r9d/build/core/build-binary.mk: 393: recipe for target 'obj/local/armeabi/objs-debug/FX_sha
Make: *** [obj/local/armeabi/objs-debug/FX_shared/_/Classes/FX_StartGame.o] Error 1
Solution: when the error CCArray does not name a type is returned, CCArray does not define the type. You can change CCArray to cocos2d: CCArray.
Sprintf_s was not in this scope
NDK supports a specific C or C ++ library. You can use sprintf to replace sprintf_s.
Other common errors
Q1: [armeabi] Compile ++ thumb: FX_shared <= FXSharedMethod. cpp
Jni/.../../Classes/FXSharedMethod. cpp: In static member function 'static char * CFXSharedMethod: G2U (char const *)':
Jni/.../../Classes/FXSharedMethod. cpp: 15: 32: error: 'cp _ ACP 'was not declared in this scope
Jni/.../../Classes/FXSharedMethod. cpp: 15: 62: error: 'multibytetowidechar 'was not declared in this scope
Jni/.../../Classes/FXSharedMethod. cpp: 19: 28: error: 'cp _ utf8' was not declared in this scope
Jni/.../../Classes/FXSharedMethod. cpp: 19: 69: error: 'widechartomultibyte 'was not declared in this scope
/Cygdrive/D/android-ndk-r9d-windows-x86/android-ndk-r9d/build/core/build-binary.mk: 393: recipe for target 'obj/local/armeabi/objs-debug/FX_shad
Make: *** [obj/local/armeabi/objs-debug/FX_shared/_/Classes/FXSharedMethod. o] Error 1
Solution: the unsupported C ++ library is used.
Problem:
The project cannot run normally after being created. The error message is displayed:
Fatal error C1083: Unable to open include file: "CCStdC. h": No such file or directory
Fatal error C1083: Unable to open include file: "SimpleAudioEngine. h": No such file or directory
Solution:
Copy the cocos2dx and CocosDenshion folders in the cocos2d-2.0-x-2.0.3 to the project directory