I was stuck when my libraries entered the Android NDK assembly.
Libraries compile correctly and work fine when creating a dummy cpp file and build everything with the direct g ++ command in the shell.
The current Android.mk file does not work and gives an error that the corresponding header files (which are part of the .a files) cannot be found.
How to enable ready-made static libraries?
My Android.mk file looks like this:
LOCAL_PATH := $(call my-dir)
The compiler output is the following, which makes sense, but only shows me that there is not a single .a file, and I donβt know why:
Compile++ thumb : v8gl-runtime <= v8gl.cpp (... g++ call) In file included from jni/../src/v8gl/v8gl.cpp:6: jni/../src/v8gl/v8gl.h:5:16: error: v8.h: No such file or directory
SOLUTION with an absolute path
Thanks to a hint of @ alex-cohn, I found out that attachments were falsely marked. Therefore, I decided to use an environment variable that was set before calling ndk-build, which contains an absolute path. This fixes the problem with the included ones.
So, the last module where the actual inclusion is performed now looks like this:
ADK_PATH=/var/whatever/to/your/project/root_not_jni include $(CLEAR_VARS) LOCAL_MODULE := v8gl-runtime LOCAL_SRC_FILES := main.c ../src/v8gl/v8gl.cpp LOCAL_C_INCLUDES:= $(ADK_PATH)/external/v8/include LOCAL_CPPFLAGS := -D__ANDROID__ LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM LOCAL_STATIC_LIBRARIES := android_native_app_glue v8_base v8_nosnapshot
Now it also shows that libraries are included because they are compiled subsequently - for any reason.
SOLUTION with a relative path
All included paths refer to the project root folder, not the jni folder. This means that it will land as a compiler. I flag something like this:
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../file_in_project.root
So there is a difference between the relative include and LOCAL_SRC_FILES paths that belong to the jni folder!