Missing header files compiling for Android

Hello!

I try to compile my game for android devices and I get errors like this:

fatal error: IGame.h: No such file or directory
 #include "IGame.h"

which is absurd because all the header files are there :confused:

I don’t know what could be the problem. My Android.mk file looks like this:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)


LOCAL_MODULE := cocos2dcpp_shared

LOCAL_MODULE_FILENAME := libcocos2dcpp

LOCAL_SRC_FILES := hellocpp/main.cpp \
                  ../../Classes/AppDelegate.cpp \
                  ../../Classes/BasicClasses/GameSettings.cpp \
                  ../../Classes/Interfaces/IGetReady.cpp \
                  ../../Classes/Interfaces/IScene.cpp \
                  ../../Classes/Nodes/ImageSprite.cpp \
                  ../../Classes/Nodes/PlateSprite.cpp \
                  ../../Classes/Scenes/ColorGameScene.cpp \
                  ../../Classes/Scenes/GetReadyLayer.cpp \
                  ../../Classes/SoundManagers/SoundManager.cpp

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

# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END


LOCAL_STATIC_LIBRARIES := cocos2dx_static

# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END

include $(BUILD_SHARED_LIBRARY)

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

# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END

Is it because I don’t have the files in the Classes folder but inside some subfolders in Classes?

Also the IGame.h is a .h standalone file. What about those?

EDIT:

Found the solution! Had to add this to my .mk file:

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Classes/BasicClasses
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Classes/Interfaces
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Classes/Nodes
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Classes/Scenes
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Classes/SoundManagers

Just for solution exhaustion you could also have put the paths in the include statements.

#include "Interfaces/IGame.h"

I suppose it’s probably easier to hassle with the project setup once than specify paths everywhere. Depends on if you value being able to move a header file to another directory, but then you may want to use the same named header in multiple places and may find locating header files quicker by knowing its path location?

1 Like