Cocos2d-x 3.2編譯生成Android程序出錯的解決方案:c++_static報錯

最近升級到Cocos2d-x 3.2正式版,iOS程序編譯沒任何問題,結果使用cocos compile -p android編譯生成APK程序,結果悲劇了,出現如下錯誤。 html

Android NDK: Invalid APP_STL value: c++_static android

Android NDK: Please use one of the following instead:  system stlport_static stlport_static_hard stlport_shared stlport_shared_hard gnustl_static gnustl_shared gabi++_static gabi++_shared libc++_static libc++_shared none c++

make: Entering directory `/game/physics_engine/proj.android' app

/sdk/ndk/android-ndk-r9c/build/core/add-application.mk:274: *** Android NDK: Aborting    .  Stop. ui

make: Leaving directory `/game/physics_engine/proj.android' atom

Error running command, return code: 2 c++11

很顯然,這個錯誤是使用了不正確的STL Library,解決方案有以下兩個。 code

方案1:臨時方案 htm

修改Application.mk文件,將原來的前4行替換爲以下的內容。而後替換就ok了 it

原來的內容以下:

APP_STL := c++_static

NDK_TOOLCHAIN_VERSION=clang

APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char

APP_LDFLAGS := -latomic

替換後的內容以下:

APP_STL := gnustl_static

  

APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 -std=c++11 -Wno-literal-suffix -fsigned-char  

方案2:

因爲c++_static只有在最新的NDK中才可以使用,因此下載最新的NDK就能夠了

你們能夠從http://developer.android.com/tools/sdk/ndk/index.html下載最新的NDK版本,而後重新設置ndk路徑便可。

相關文章
相關標籤/搜索