在ndk專案常常會遇到,像是編譯ffmpeg專案,應該都會遇到這種錯誤> #include "ffmpeg.h" error: ffmpeg.h: No such file or directory",大致上就是說不到對應的ffmpeg.h檔案,這時候就得加入LOCAL_C_INCLUDES來引入對應的.h檔案

# 配置自己的源文件目錄和源文件後綴名
MY_FILES_PATH  :=  $(LOCAL_PATH) \
                   $(LOCAL_PATH)/../../Classes
MY_FILES_SUFFIX := %.cpp %.c
# 遞歸遍歷目錄下的所有的文件
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
# 獲取相應的源文件
MY_ALL_FILES := $(foreach src_path,$(MY_FILES_PATH), $(call rwildcard,$(src_path),*.*) ) 
MY_ALL_FILES := $(MY_ALL_FILES:$(MY_CPP_PATH)/./%=$(MY_CPP_PATH)%)
MY_SRC_LIST  := $(filter $(MY_FILES_SUFFIX),$(MY_ALL_FILES)) 
MY_SRC_LIST  := $(MY_SRC_LIST:$(LOCAL_PATH)/%=%)
# 去除字串的重複單詞
define uniq =
  $(eval seen :=)
  $(foreach _,$1,$(if $(filter $_,${seen}),,$(eval seen += $_)))
  ${seen}
endef
# 遞歸遍歷獲取所有目錄
MY_ALL_DIRS := $(dir $(foreach src_path,$(MY_FILES_PATH), $(call rwildcard,$(src_path),*/) ) )
MY_ALL_DIRS := $(call uniq,$(MY_ALL_DIRS))
# 賦值給NDK編譯系統
LOCAL_SRC_FILES  := $(MY_SRC_LIST)
LOCAL_C_INCLUDES := $(MY_ALL_DIRS)
創作者介紹

宇若彎彎

周宇若 發表在 痞客邦 PIXNET 留言(0) 人氣()