gpt4 book ai didi

android - (Cocos2dx-v3) Android - 如何解决 "cocos2d.h: No such file or directory"?

转载 作者:搜寻专家 更新时间:2023-11-01 09:45:45 25 4
gpt4 key购买 nike

在我的 cocos2dx 项目目录的终端中,我输入了

$ cocos run test -p android

然后出现这个错误日志。

[armeabi-v7a] Compile++ thumb: MyGame_shared <= main.cpp
[armeabi-v7a] Compile++ thumb: MyGame_shared <= AppDelegate.cpp
[armeabi-v7a] Compile++ thumb: MyGame_shared <= HelloWorldScene.cpp
[armeabi-v7a] Compile++ thumb: MyGame_shared <= CharacterSelectScene.cpp
[armeabi-v7a] Compile++ thumb: MyGame_shared <= LanguageManager.cpp
[armeabi-v7a] Compile++ thumb: MyGame_shared <= GameMaster.cpp
[armeabi-v7a] Compile++ thumb: MyGame_shared <= Player.cpp
[armeabi-v7a] StaticLibrary : libextension.a
In file included from jni/../../Classes/HelloWorldScene.cpp:1:0:
jni/../../Classes/HelloWorldScene.h:4:21: fatal error: cocos2d.h: No such file or directory
#include "cocos2d.h"
^
compilation terminated.
In file included from jni/hellocpp/main.cpp:1:0:
jni/../../Classes/AppDelegate.h:4:21: fatal error: cocos2d.h: No such file or directory
#include "cocos2d.h"
^
compilation terminated.
In file included from jni/../../Classes/AppDelegate.cpp:1:0:
jni/../../Classes/AppDelegate.h:4:21: fatal error: cocos2d.h: No such file or directory
#include "cocos2d.h"
^
compilation terminated.
make: *** [obj/local/armeabi-v7a/objs-debug/MyGame_shared/__/__/Classes/HelloWorldScene.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [obj/local/armeabi-v7a/objs-debug/MyGame_shared/__/__/Classes/AppDelegate.o] Error 1
make: *** [obj/local/armeabi-v7a/objs-debug/MyGame_shared/hellocpp/main.o] Error 1
In file included from jni/../../Classes/Player.cpp:9:0:
jni/../../Classes/Player.h:12:21: fatal error: cocos2d.h: No such file or directory
#include "cocos2d.h"
^
compilation terminated.
In file included from jni/../../Classes/GameMaster.cpp:9:0:
jni/../../Classes/GameMaster.h:12:21: fatal error: cocos2d.h: No such file or directory
#include "cocos2d.h"
^
compilation terminated.
make: *** [obj/local/armeabi-v7a/objs-debug/MyGame_shared/__/__/Classes/Player.o] Error 1
make: *** [obj/local/armeabi-v7a/objs-debug/MyGame_shared/__/__/Classes/GameMaster.o] Error 1
In file included from jni/../../Classes/CharacterSelectScene.cpp:9:0:
jni/../../Classes/CharacterSelectScene.h:12:21: fatal error: cocos2d.h: No such file or directory
#include "cocos2d.h"
^
compilation terminated.
make: *** [obj/local/armeabi-v7a/objs-debug/MyGame_shared/__/__/Classes/CharacterSelectScene.o] Error 1
In file included from jni/../../Classes/LanguageManager.cpp:2:0:
jni/../../Classes/LanguageManager.h:8:21: fatal error: cocos2d.h: No such file or directory
#include "cocos2d.h"
^
compilation terminated.
make: *** [obj/local/armeabi-v7a/objs-debug/MyGame_shared/__/__/Classes/LanguageManager.o] Error 1
Error running command, return code: 2.

我在链接中发现了类似的问题

Cocos2d.h No such file or directory

但是我不知道怎么办

 "add the path to the folder that contains the cocos2d.h header file"

谁能告诉我解决这个问题的步骤?

最佳答案

这可能是您使用 cocos2d-x 开始新生活后遇到的非常烦人的错误之一。有几件事需要检查。

Import the libcocos2dx from eclipse

Ctrl + N

> Android Project from Existing Code 
> yourDirectory\cocos2d-x-3.yourVersion\cocos2d\cocos\platform

如果这没有帮助,请添加,您需要在 Android.mk 中提供您的类和 .cpp 文件的绝对路径,我相信这是您所需要的。

展开您的项目列表(我假设 test 是您的项目名称)

   > test 
> jni
> Android.mk

替换这个:

LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp \
../../Classes/GameMaster.cpp \
../../Classes/MyGame_shared.cpp \

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes

有了这个:

CPP_FILES := $(shell find $(LOCAL_PATH)/../../Classes -name *.cpp)
LOCAL_SRC_FILES := hellocpp/main.cpp
LOCAL_SRC_FILES += $(CPP_FILES:$(LOCAL_PATH)/%=%)
LOCAL_C_INCLUDES := $(shell find $(LOCAL_PATH)/../../Classes -type d)

关于android - (Cocos2dx-v3) Android - 如何解决 "cocos2d.h: No such file or directory"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38214714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com