Android.mk relative or absolute paths?

I am trying to create a project using android ndk (on Windows) and I am having some problems with the source files ( LOCAL_SRC_FILES on Android.mk)

I am trying to use relative paths to the parent folder like

LOCAL_SRC_FILES := ../../../src/main.cpp

And when running ndk_build.cmd, it produces the following error:

 Compile++ thumb : GTP <= main.cpp The system cannot find the file specified. make: *** [obj/local/armeabi/objs/GTP/__/__/__/src/.o] Error 1 

So, I tried using absolute paths:

 LOCAL_SRC_FILES := D:/Path/To/src/main.cpp 

Unfortunately, this does not work, because : causes problems in windows .

Is it possible to specify the source files in a relative directory (or absolute)? The reason I'm asking is because I want to avoid a possible symbolic link to the src folder, if possible.

+6
source share
3 answers

According to the ndk documentation, it is recommended to use relative paths and the following macro (Android.mk uses make file syntax):

  LOCAL_PATH := $(call my-dir) An Android.mk file must begin with the definition of the LOCAL_PATH variable. It is used to locate source files in the development tree. In this example, the macro function 'my-dir', provided by the build system, is used to return the path of the current directory (ie the directory containing the Android.mk file itself). 

So you can replace LOCAL_SRC_FILES with something similar to:

 LOCAL_SRC_FILES := $(LOCAL_PATH)/../../../src/main.cpp 
+7
source

The easiest way to work with source files, distributed across many directories, is to compile separate static libraries for each directory or group of directories. In the NDK, these libraries are called "modules." For each module, you specify LOCAL_SRC_PATH in Android.mk. LOCAL_SRC_FILES belong to this path. The caveat is that LOCAL_C_INCLUDES, etc. Refers to the project root directory (usually above the jni directory).

Your project may have many Android.mk files, but you can create many modules with one Android.mk.

0
source

Try the following:

 LOCAL_PATH:=$(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := YOUR_SRC_IN_LIB_JNI 
0
source

Source: https://habr.com/ru/post/957160/


All Articles