Cocos2d-x 3.X构建Android" cocos2d.h"文件未找到

时间:2015-05-20 12:42:05

标签: android cocos2d-x

我正在使用build_native.py来构建Android平台,但它说 "致命错误:致命错误:' cocos2d.h'文件未找到"。 在此问题出现之前,它说不能导入导入模块,我在环境变量中设置了NDK_MODULD_PATH来修复它我不知道这是否会导致这个问题。

In file included from jni/hellocpp/main.cppIn file included from 

jni/../../Class
es/AppDelegate.cppIn file included from jni/../../Classes/GameOverScene.cpp:1:
::jni/../../Classes/GameOverScene.h1:
:4:10: jni/../../Classes/AppDelegate.hfatal error: :4'cocos2d.h' file not found1
:

In file included from #include "cocos2d.h"

这是我的Android.mk

LOCAL_PATH := $(call my-dir)

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

LOCAL_SRC_FILES := hellocpp/main.cpp \
                   ../../Classes/AppDelegate.cpp \
                   ../../Classes/Adapter.cpp \
                   ../../Classes/ControlLayer.cpp \
                   ../../Classes/GameOverScene.cpp \
                   ../../Classes/GameRunScene.cpp \
                   ../../Classes/GameStartScene.cpp \
                   ../../Classes/SceneManager.cpp \
                   ../../Classes/HelloWorldScene.cpp

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../cocos2d/cocos/physics
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Classes

LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../libcocos2d

LOCAL_STATIC_LIBRARIES := cocos2dx_static
LOCAL_STATIC_LIBRARIES := cocos2dx_extension_static

LOCAL_LDLIBS += -L$(call host-path,$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(TARGET_ARCH_ABI)) -lc++_static

include $(BUILD_SHARED_LIBRARY)

$(call import-module,./prebuilt-mk)

2 个答案:

答案 0 :(得分:0)

在这种情况下,大多数错误来自NDK_MODULD_PATH的错误路径设置。我曾经在使用Cocos2d-x 2.2.6时遇到this error。我建议您再次检查NDK_MODULE_PATH的路径以将其设置为

${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source;${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt

将$ {COCOS2DX_ROOT}替换为您自己的路径。你也可以查看article,虽然它是在讨论Cocos2d-x 2.x。

答案 1 :(得分:0)

当我使用cocos2d-x-3.7时,我也错过了这个错误。我的解决方案是在 jni / Android.mk 设置:

  

LOCAL_STATIC_LIBRARIES:= cocos2d_lua_static

详情请见FixBug