In terminal at my cocos2dx project directory, I typed
$ cocos run test -p android
and comes this error log.
[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.
I found the similar problem in the link
Cocos2d.h No such file or directory
But I didn't know how to
"add the path to the folder that contains the cocos2d.h header file"
Can anyone tell me steps to solving this problem?
This is probably one of the very annoying errors that you get once you start your new life with cocos2d-x
. There are a couple of things to get a check on.
Import the libcocos2dx from eclipse
Press Ctrl + N
> Android Project from Existing Code
> yourDirectory\cocos2d-x-3.yourVersion\cocos2d\cocos\platform
Add if that does not help, you need to give absolute paths to your classes and .cpp
files in Android.mk
which I believe is what you need.
Expand your project list (I have assumed test
is your project name)
> test
> jni
> Android.mk
Replace this:
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
With this:
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)