歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Cocos2D-X 3.2編譯生成Android程序出錯的解決方案

Cocos2D-X 3.2編譯生成Android程序出錯的解決方案

日期:2017/3/1 9:38:18   编辑:Linux編程

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

Android NDK: Invalid APP_STL value: c++_static

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

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

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

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

Error running command, return code: 2

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

方案1:臨時方案

修改Application.mk文件,將原來的前4行替換為如下的內容。然後替換就ok了

原來的內容如下:

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路徑即可。

剖析cocos2d-x之Action實現 http://www.linuxidc.com/Linux/2013-04/82436.htm

Ubuntu下cocos2d-x開發環境搭建及配置 http://www.linuxidc.com/Linux/2013-03/81876.htm

Cocos2d-x3.2實現虛擬搖桿多點觸摸 http://www.linuxidc.com/Linux/2014-09/106551.htm

Ubuntu 14.04搭建Cocos2d-x2.2.5開發環境圖文詳解 http://www.linuxidc.com/Linux/2014-10/108108.htm

Cocos2D-X 的詳細介紹:請點這裡
Cocos2D-X 的下載地址:請點這裡

更多Android相關信息見Android 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=11

Copyright © Linux教程網 All Rights Reserved