问题描述
我试图建立一个使用NDK的Android项目,但我遇到了一些麻烦。
I'm trying to build an Android project using the ndk, but I have run into some troubles.
这里的Android.mk文件如下:
Here's the Android.mk file that works:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := mylib
LOCAL_CFLAGS := -Werror
LOCAL_SRC_FILES := main.cpp, Screen.cpp, ScreenManager.cpp
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
有没有一种方法,可以让我在指定目录下的所有* .cpp文件,没有LOCAL_SRC_FILES下手动列出来?
Is there a way that allows me to specify all the *.cpp files in the directory, without listing them manually under LOCAL_SRC_FILES?
到目前为止,我试图用LOCAL_SRC_FILES = $(通配符*的.cpp),但它没有现在的工作,似乎没有文件被选中。
So far I tried using LOCAL_SRC_FILES = $(wildcard *.cpp), but it did now work, it seems that no files get selected.
推荐答案
您可以尝试这样的事情...
You could try something like this...
FILE_LIST := $(wildcard $(LOCAL_PATH)/[DIRECTORY]/*.cpp)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
...修改 [DIRECTORY]
的文件的实际目录。如果他们是在相同的目录的.mk
文件然后删除该部分。创建 file_list中
变量来查找所有的的.cpp
文件下的 [DIRECTORY]
目录。然后把它用在文件清单。该 LOCAL_SRC_FILES
行,将消除 LOCAL_PATH
从上市。
... Change [DIRECTORY]
to the actual directory of the files. If they are in the same directory as your .mk
file then remove that part. Create the FILE_LIST
variable to find all of the .cpp
files under the [DIRECTORY]
directory. Then use it in the file listing. The LOCAL_SRC_FILES
line will then remove the LOCAL_PATH
from the listing.
这篇关于Android.mk,包括所有的cpp文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!