1. 程式人生 > >解決fatal error: sys/system_properties.h: No such file or directory compilation terminated.

解決fatal error: sys/system_properties.h: No such file or directory compilation terminated.

編譯的異常log:

system/core/include/cutils/properties.h:22:35: fatal error: sys/system_properties.h: No such file or directory
compilation terminated.
make[1]: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libinput_intermediates/<strong>xxxxx</strong>.o] 錯誤 1
make[1]:正在離開目錄 `/home/<strong>xxxx</strong>/code/<strong>xxxxx</strong>/kk/bra_<strong>xxxx</strong>/alps'
                    ==> [FAIL]  2015/03/20 17:16:54
make: *** [mm] 錯誤 2

分析: 編譯不過是由於BUILD_HOST_STATIC_LIBRARY沒有引用相應的靜態庫,在mk檔案引用相應靜態庫,編譯通過。

修改Android.mk檔案:

LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_LIBRARIES := \
    libcutils \

include $(BUILD_HOST_STATIC_LIBRARY)

如果找不到對應模組的mk檔案可用下面這條命令嘗試搜尋:

//下面的xxxx.cpp可以使編譯模組中的檔案,最好是你修改之後的檔案

find -name *.mk | xargs grep "xxxx.cpp" -nsr --color=auto

注!上面xxxx為了避免敏感資訊而用xxxx來代替。本人對於編譯指令碼和底層並不是很熟悉,因此對這個解決過程比較痛苦,所以留下這篇部落格與遇到此類問題的朋友共勉,也希望大家能夠理解這種分享的精神。