Android.mk相对路径还是绝对路径?

Bra*_*rad 7 c++ android android-ndk

我正在尝试使用android ndk(在Windows上)构建一个项目,我有一些专门针对源文件的问题(LOCAL_SRC_FILES在Android.mk中)

我正在尝试使用相对路径到父文件夹,如

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

运行ndk_build.cmd时,它会输出以下错误:

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

所以我尝试使用绝对路径:

LOCAL_SRC_FILES := D:/Path/To/src/main.cpp
Run Code Online (Sandbox Code Playgroud)

不幸的是,这不起作用,因为Windows上:原因问题

有什么办法可以在相对目录(或绝对)中指定源文件吗?我问的原因是因为我想避免在可能的情况下建立到src文件夹的符号链接.

Mic*_*ael 10

根据ndk文档,建议使用相对路径和以下宏(Android.mk使用make文件的语法):

  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 (i.e. the directory containing the
Android.mk file itself).
Run Code Online (Sandbox Code Playgroud)

所以你可以用类似的东西替换你的LOCAL_SRC_FILES:

LOCAL_SRC_FILES := $(LOCAL_PATH)/../../../src/main.cpp
Run Code Online (Sandbox Code Playgroud)