我正在嘗試將外部庫添加到我的專案中。
我的專案結構如下所示:
-project
-- main
--- main.c
--- displayfunctions.c (where i implement my Displayfunctions based on the library)
--- 2 other .c files which got nothing to do with my Display
--- CMakeLists.txt
-- components
--- displaylibrary
---- CMAKELists.txt
---- all displayrelevant librarys pngle.c fontx.c etc..
---- include
----- all corresponding header files pngle.h fontx.h etc.
我在 project/components/displaylibrarys 中的 CMakeLists.txt 檔案如下所示:
idf_component_register(SRCS "pngle.c" "decode_jpeg.c" "decode_png.c" "fontx.c" "ili9340.c"
INCLUDE_DIRS "include" )
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
當我嘗試編譯我的專案時,我收到以下錯誤訊息:
../components/Displaylibrarys/fontx.c:7:10: fatal error: esp_spiffs.h: No such file or directory #include "esp_spiffs.h"
所以顯然我的編譯器沒有將我的外部庫中包含的 esp-idf 庫與實際的 esp-idf 庫鏈接起來。我也用這種方法試過了
idf_component_register(SRCS "pngle.c" "decode_jpeg.c" "decode_png.c" "fontx.c" "ili9340.c"
INCLUDE_DIRS "include"
REQUIRES esp_spiffs)
但沒有結果。我應該如何正確地告訴我的編譯器它知道這個庫?
uj5u.com熱心網友回復:
ESP-IDF 構建系統與組件一起作業。您的庫是一個組件,ESP-IDF 庫的許多部分也是如此。
作為組件方法的一部分,您的組件需要宣告它所依賴的其他組件。這就是該REQUIRES條款的用途。
除了呼叫組件spiffs而不是esp_spiffs.
idf_component_register(SRCS "pngle.c" "decode_jpeg.c" "decode_png.c" "fontx.c" "ili9340.c"
INCLUDE_DIRS "include"
REQUIRES spiffs)
我通常檢查 ESP-IDF 組件目錄以找出正確的名稱。組件和目錄名稱相同:https : //github.com/espressif/esp-idf/tree/master/components
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/372284.html
標籤:视觉工作室代码 ESP32 目录结构 esp-idf cmakelists-选项
