cocos2d-x发生undefined reference to `XX'异常 一劳永逸解决办法

前端之家收集整理的这篇文章主要介绍了cocos2d-x发生undefined reference to `XX'异常 一劳永逸解决办法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

转载:

http://blog.csdn.net/gf771115/article/details/34414449

cocos2d-x发生undefined reference to `XX'错误 一劳永逸解决方法

原因是android的nkd编译需要将每个cpp尽心进行声明进入jni目录下的Android.mk

将:

LOCAL_SRC_FILES := AppDelegate.cpp \
HelloWorldScene.cpp

修改为:

LOCAL_MODULE_FILENAME := libcocos2dcpp


MY_CPP_LIST := $(wildcard $(LOCAL_PATH)/*.cpp)
MY_CPP_LIST += $(wildcard $(LOCAL_PATH)/hellocpp/*.cpp)
MY_CPP_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp)
//这个是新增的tidy目录

MY_CPP_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/tidy/*.c)


LOCAL_SRC_FILES := $(MY_CPP_LIST:$(LOCAL_PATH)/%=%)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes

--------

下面是一个Android.mk例子:

LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocos2dcpp_shared LOCAL_MODULE_FILENAME := libcocos2dcpp MY_CPP_LIST := $(wildcard $(LOCAL_PATH)/*.cpp) MY_CPP_LIST += $(wildcard $(LOCAL_PATH)/hellocpp/*.cpp) MY_CPP_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp) LOCAL_SRC_FILES := $(MY_CPP_LIST:$(LOCAL_PATH)/%=%) LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static LOCAL_WHOLE_STATIC_LIBRARIES += Box2d_static LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static include $(BUILD_SHARED_LIBRARY) $(call import-module,cocos2dx) $(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) $(call import-module,CocosDenshion/android) $(call import-module,extensions) $(call import-module,external/Box2D) $(call import-module,external/chipmunk)

原文链接:https://www.f2er.com/cocos2dx/339102.html

猜你在找的Cocos2d-x相关文章