cocos2dx在安卓下編譯報錯error1:libcocos2dcpp.so 無法生成
阿新 • • 發佈:2019-02-16
一、首先第一點要確定自己選擇的 NDK 版本是否存在問題,是否與專案所需匹配 ,正常編譯過程會自動選擇預設的NDK 版本,但是這也會導致了libcocos2dcpp.so 庫檔案無法成功生成, 更改方法 ,可以在 android 下的 jni=》選擇application,mk 檔案 ,新增 如:NDK_TOOLCHAIN_VERSION = 4.9
下面給個application.mk大致配置方法:
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_DEBUG := $(strip $(NDK_DEBUG)) ifeq ($(APP_DEBUG),1) APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 APP_OPTIM := debug else APP_CPPFLAGS += -DNDEBUG APP_OPTIM := release endif NDK_TOOLCHAIN_VERSION = 4.9
二、第二點要考慮的是否把專案下的所有cpp檔案都新增到了 android.mk檔案下,是否有重複新增,並且要新增編譯時 專案所需的SDK 庫 和 所需要包含的 cocos2dx 庫的 路徑,還要加好說需要的標頭檔案路徑 比如: cocos2d/extensions 標頭檔案等。
下面給個android.mk檔案的大致配置方法:
LOCAL_PATH := $(call my-dir) ############################################################################################################ # fmod (音訊)#編譯程式所需要的庫 # fmodex include $(CLEAR_VARS) LOCAL_MODULE := fmodex LOCAL_SRC_FILES := ../../Classes/sdk/fmod/android/api/lib/$(TARGET_ARCH_ABI)/libfmodex.so include $(PREBUILT_SHARED_LIBRARY) # fmodevent include $(CLEAR_VARS) LOCAL_MODULE := fmodevent LOCAL_SRC_FILES := ../../Classes/sdk/fmod/android/fmoddesignerapi/api/lib/$(TARGET_ARCH_ABI)/libfmodevent.so include $(PREBUILT_SHARED_LIBRARY) ############################################################################################################ include $(CLEAR_VARS) $(call import-add-path,$(LOCAL_PATH)/../../cocos2d) $(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external) $(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos) LOCAL_MODULE := cocos2dcpp_shared LOCAL_MODULE_FILENAME := libcocos2dcpp FILE_LIST := hellocpp/main.cpp # sdk cpp程式碼的新增 FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/sdk/fmod/*.cpp) # 基礎庫 #cpp程式碼的新增 FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp) LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%) # 標頭檔案路徑 LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../cocos2d/extensions ############################################################################################################ # 靜態庫 LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static # LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static # LOCAL_WHOLE_STATIC_LIBRARIES += cocosbuilder_static # LOCAL_WHOLE_STATIC_LIBRARIES += spine_static # LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static # LOCAL_WHOLE_STATIC_LIBRARIES += cocos_network_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static # 第三方sdk 靜態庫 LOCAL_WHOLE_STATIC_LIBRARIES += libiconv_static # LOCAL_WHOLE_STATIC_LIBRARIES += libsqlite3_static ############################################################################################################ # 動態庫 # fmod(音訊) LOCAL_SHARED_LIBRARIES += fmodex LOCAL_SHARED_LIBRARIES += fmodevent ############################################################################################################ include $(BUILD_SHARED_LIBRARY) $(call import-module,.) $(call import-module,audio/android) # $(call import-module,Box2D) # $(call import-module,editor-support/cocosbuilder) # $(call import-module,editor-support/spine) # $(call import-module,editor-support/cocostudio) # $(call import-module,network) $(call import-module,extensions) ############################################################################################################ # 第三方sdk # 編碼轉換 $(call import-module,../Classes/sdk/libiconv) # 資料庫 # $(call import-module, ../Classes/sdk/sqlite3) ############################################################################################################ ###等等 等等。。。