Page 1 of 1

#include gives no such file or directory (IDFGH-4287)

Posted: Wed Nov 18, 2020 6:10 pm
by veelox
Hi, my project tree look like this

TOP LEVEL FOLDER:
- main folder
- component folder
- CMakeLists.txt with :
  1.  
  2. cmake_minimum_required(VERSION 3.5)
  3. set(SUPPORTED_TARGETS esp32)
  4. include($ENV{IDF_PATH}/tools/cmake/project.cmake)
  5. project(FirmwareRTOS)  

MAIN FOLDER :
- main.cpp
- main.h
- component.mk (empty)
- CMakeLists.txt :
  1. idf_component_register(SRCS "main.cpp" INCLUDE_DIRS ".")

COMPONENT FOLDER :
- Sensor folder
- STC3115_Drivers folder

STC3115_DRIVERS FOLDER :
- stc3115_Battery.h
- stc3115_Driver.cpp /.h
- stc3115_I2C.cpp /.h
- component.mk (empty)
- CMakeLists.txt :
  1. idf_component_register(SRCS "stc3115_Driver.cpp" "stc3115_I2C.cpp" INCLUDE_DIRS ".")

SENSOR FOLDER :
- sensor.cpp / .h
- sensorInit.cpp / .h
- sensorRoutine.cpp / .h
- component.mk (empty)
- CMakeLists.txt :
  1. idf_component_register(SRCS "sensor.cpp" "sensorInit.cpp" "sensorRoutine.cpp" INCLUDE_DIRS ".")

Inside sensorInit.h there is
  1. #include "stc3115_Driver.h"
i get the following error :
  1. No such file or directory

I've tried adding an include folder in every component folder and into the previous component.mk i've added :
  1. COMPONENT_SRCDIRS := .
  2. COMPONENT_ADD_INCLUDEDIRS := include/
No success

Re: #include gives no such file or directory

Posted: Wed Nov 18, 2020 11:48 pm
by ESP_Angus
Hi Veelox,

Each component needs to declare the other components that it depnds on (requires). So in this case the "sensor" component needs to have "REQUIRES stc3115_drivers" added to the idf_component_register arguments list.

For more details see https://docs.espressif.com/projects/esp ... quirements

Angus

Re: #include gives no such file or directory (IDFGH-4287)

Posted: Thu Nov 19, 2020 1:02 pm
by veelox
This solution work, thanks you for your help.
Regarding include from esp idf component, which relative file i'm suppose to be in.
am i starting in ../esp-idf/components/any file/include? Am i calling #include <driver/gpio.h>?

Re: #include gives no such file or directory (IDFGH-4287)

Posted: Thu Nov 19, 2020 11:43 pm
by ESP_Angus
veelox wrote:
Thu Nov 19, 2020 1:02 pm
This solution work, thanks you for your help.
Regarding include from esp idf component, which relative file i'm suppose to be in.
am i starting in ../esp-idf/components/any file/include? Am i calling #include <driver/gpio.h>?
You shouldn't have to pass any relative paths like this.

If your component needs to include headers from the "driver" component, then add "REQUIRES driver" in the CMakeLists.txt file idf_component_register call. The build system will then know that when it compiles files from your component, it should make the headers from "driver" available.

Re: #include gives no such file or directory (IDFGH-4287)

Posted: Thu Nov 26, 2020 4:09 pm
by veelox
Is there any particular reason why adding another component gives me again no such file or directory? Even with the REQUIRES field completed in the idf_component_register?

ex: component folder with
- component1 folder
- CMakeLists.txt
- .c/.h
- component2 folder
- CMakeLists.txt
- .c/.h
- component3 folder
- CMakeLists.txt
- .c/.h

.h in component2 can call header in component1 but not component3 even if component2 has idf_component_register(..... REQUIRES component1 component3)

CMakeLists in the main folder contains REQUIRES component1/2/3

Re: #include gives no such file or directory (IDFGH-4287)

Posted: Thu Nov 26, 2020 9:00 pm
by ESP_Angus
Hi veelox,

This sounds like it should work. Could you post the full contents of each idf_component_register() line, and the full build output? Is the file being compiled that triggers the error part of component2?

The "main" component is special, it automatically REQUIREs all the other components, so you don't need a REQUIRES line inside the main component itself. However it shouldn't be a problem to add one.

Re: #include gives no such file or directory (IDFGH-4287)

Posted: Fri Nov 27, 2020 1:59 pm
by veelox
MAIN FOLDER
- main.cpp/main.h
- CMakeLists.txt :
  1. idf_component_register(SRCS "main.cpp"
  2.                     INCLUDE_DIRS "."
  3. REQUIRES STC3115_Drivers Filters ICM_20948 ibNavSix driver esp32)
COMPONENT FOLDER
- STC3115_Drivers folder
- Filters folder
- ICM_20948 folder
- ibNavSix folder
- BME680 folder

FILTERS FOLDER
- filters.cpp/filters.h
-CMakeLists.txt :
  1. idf_component_register(SRCS
  2. "filters.cpp"
  3. INCLUDE_DIRS ".")
ICM_20948 FOLDER
- ICM_20948.cpp/.h
- ICM_20948_C.c/.h
- CMakeLists.txt :
  1. idf_component_register(SRCS
  2. "ICM_20948.cpp"
  3. "ICM_20948_C.c"
  4. REQUIRES driver)
IBNAVSIX FOLDER
- ibNavSixInitialization.cpp/.h
- ibNavRoutine.cpp/.h
- CMakeLists.txt :
  1. idf_component_register(SRCS
  2. "ibNavSixInitialization.cpp"
  3. "ibNavRoutine.cpp"
  4. INCLUDE_DIRS "."
  5. REQUIRES ICM_20948 STC3115_Drivers Filters driver esp32 BME680)
in my ibNavSixInitialisation.h :
  1. #include "stc3115_Driver.h"
  2. #include "filters.cpp"
  3. #include "bme680.h"        //From another component folder
  4. #include "ICM_20948.h"
I got an error only on ICM_20948

[5/80] Building CXX object esp-idf/ibNavSix/CMakeFiles/__idf_ibNavSix.dir/ibNavSixInitialization.cpp.obj
FAILED: esp-idf/ibNavSix/CMakeFiles/__idf_ibNavSix.dir/ibNavSixInitialization.cpp.obj
ccache C:\Users\lassena\.espressif\tools\xtensa-esp32-elf\esp-2020r2-8.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-g++.exe -Iconfig -I../components/ibNavSix -IC:/repos/esp-idf/components/newlib/platform_include -IC:/repos/esp-idf/components/freertos/include -IC:/repos/esp-idf/components/heap/include -IC:/repos/esp-idf/components/log/include -IC:/repos/esp-idf/components/lwip/include/apps -IC:/repos/esp-idf/components/lwip/include/apps/sntp -IC:/repos/esp-idf/components/lwip/lwip/src/include -IC:/repos/esp-idf/components/lwip/port/esp32/include -IC:/repos/esp-idf/components/lwip/port/esp32/include/arch -IC:/repos/esp-idf/components/soc/esp32/include -IC:/repos/esp-idf/components/soc/include -IC:/repos/esp-idf/components/esp_rom/include -IC:/repos/esp-idf/components/esp_common/include -IC:/repos/esp-idf/components/xtensa/include -IC:/repos/esp-idf/components/xtensa/esp32/include -IC:/repos/esp-idf/components/esp32/include -IC:/repos/esp-idf/components/driver/include -IC:/repos/esp-idf/components/driver/esp32/include -IC:/repos/esp-idf/components/esp_ringbuf/include -IC:/repos/esp-idf/components/efuse/include -IC:/repos/esp-idf/components/efuse/esp32/include -IC:/repos/esp-idf/components/vfs/include -IC:/repos/esp-idf/components/esp_wifi/include -IC:/repos/esp-idf/components/esp_wifi/esp32/include -IC:/repos/esp-idf/components/esp_event/include -IC:/repos/esp-idf/components/esp_netif/include -IC:/repos/esp-idf/components/esp_eth/include -IC:/repos/esp-idf/components/tcpip_adapter/include -IC:/repos/esp-idf/components/app_trace/include -I../components/STC3115_Drivers -I../components/Filters -I../components/BME680 -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -std=gnu++11 -fno-exceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER=\"v4.1-dirty\" -DESP_PLATFORM -MD -MT esp-idf/ibNavSix/CMakeFiles/__idf_ibNavSix.dir/ibNavSixInitialization.cpp.obj -MF esp-idf\ibNavSix\CMakeFiles\__idf_ibNavSix.dir\ibNavSixInitialization.cpp.obj.d -o esp-idf/ibNavSix/CMakeFiles/__idf_ibNavSix.dir/ibNavSixInitialization.cpp.obj -c ../components/ibNavSix/ibNavSixInitialization.cpp
In file included from ../components/ibNavSix/ibNavSixInitialization.cpp:1:
../components/ibNavSix/ibNavSixInitialization.h:7:10: fatal error: ICM_20948.h: No such file or directory
#include "ICM_20948.h"
^~~~~~~~~~~~~
compilation terminated.
[6/80] Building CXX object esp-idf/ibNavSix/CMakeFiles/__idf_ibNavSix.dir/ibNavSixRoutine.cpp.obj
FAILED: esp-idf/ibNavSix/CMakeFiles/__idf_ibNavSix.dir/ibNavSixRoutine.cpp.obj
ccache C:\Users\lassena\.espressif\tools\xtensa-esp32-elf\esp-2020r2-8.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-g++.exe -Iconfig -I../components/ibNavSix -IC:/repos/esp-idf/components/newlib/platform_include -IC:/repos/esp-idf/components/freertos/include -IC:/repos/esp-idf/components/heap/include -IC:/repos/esp-idf/components/log/include -IC:/repos/esp-idf/components/lwip/include/apps -IC:/repos/esp-idf/components/lwip/include/apps/sntp -IC:/repos/esp-idf/components/lwip/lwip/src/include -IC:/repos/esp-idf/components/lwip/port/esp32/include -IC:/repos/esp-idf/components/lwip/port/esp32/include/arch -IC:/repos/esp-idf/components/soc/esp32/include -IC:/repos/esp-idf/components/soc/include -IC:/repos/esp-idf/components/esp_rom/include -IC:/repos/esp-idf/components/esp_common/include -IC:/repos/esp-idf/components/xtensa/include -IC:/repos/esp-idf/components/xtensa/esp32/include -IC:/repos/esp-idf/components/esp32/include -IC:/repos/esp-idf/components/driver/include -IC:/repos/esp-idf/components/driver/esp32/include -IC:/repos/esp-idf/components/esp_ringbuf/include -IC:/repos/esp-idf/components/efuse/include -IC:/repos/esp-idf/components/efuse/esp32/include -IC:/repos/esp-idf/components/vfs/include -IC:/repos/esp-idf/components/esp_wifi/include -IC:/repos/esp-idf/components/esp_wifi/esp32/include -IC:/repos/esp-idf/components/esp_event/include -IC:/repos/esp-idf/components/esp_netif/include -IC:/repos/esp-idf/components/esp_eth/include -IC:/repos/esp-idf/components/tcpip_adapter/include -IC:/repos/esp-idf/components/app_trace/include -I../components/STC3115_Drivers -I../components/Filters -I../components/BME680 -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -std=gnu++11 -fno-exceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER=\"v4.1-dirty\" -DESP_PLATFORM -MD -MT esp-idf/ibNavSix/CMakeFiles/__idf_ibNavSix.dir/ibNavSixRoutine.cpp.obj -MF esp-idf\ibNavSix\CMakeFiles\__idf_ibNavSix.dir\ibNavSixRoutine.cpp.obj.d -o esp-idf/ibNavSix/CMakeFiles/__idf_ibNavSix.dir/ibNavSixRoutine.cpp.obj -c ../components/ibNavSix/ibNavSixRoutine.cpp
In file included from ../components/ibNavSix/ibNavSixRoutine.cpp:3:
../components/ibNavSix/ibNavSixInitialization.h:7:10: fatal error: ICM_20948.h: No such file or directory
#include "ICM_20948.h"
^~~~~~~~~~~~~
compilation terminated.
[7/80] Building CXX object esp-idf/main/CMakeFiles/__idf_main.dir/main.cpp.obj
FAILED: esp-idf/main/CMakeFiles/__idf_main.dir/main.cpp.obj
ccache C:\Users\lassena\.espressif\tools\xtensa-esp32-elf\esp-2020r2-8.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-g++.exe -Iconfig -I../main -IC:/repos/esp-idf/components/newlib/platform_include -IC:/repos/esp-idf/components/freertos/include -IC:/repos/esp-idf/components/heap/include -IC:/repos/esp-idf/components/log/include -IC:/repos/esp-idf/components/lwip/include/apps -IC:/repos/esp-idf/components/lwip/include/apps/sntp -IC:/repos/esp-idf/components/lwip/lwip/src/include -IC:/repos/esp-idf/components/lwip/port/esp32/include -IC:/repos/esp-idf/components/lwip/port/esp32/include/arch -IC:/repos/esp-idf/components/soc/esp32/include -IC:/repos/esp-idf/components/soc/include -IC:/repos/esp-idf/components/esp_rom/include -IC:/repos/esp-idf/components/esp_common/include -IC:/repos/esp-idf/components/xtensa/include -IC:/repos/esp-idf/components/xtensa/esp32/include -IC:/repos/esp-idf/components/esp32/include -IC:/repos/esp-idf/components/driver/include -IC:/repos/esp-idf/components/driver/esp32/include -IC:/repos/esp-idf/components/esp_ringbuf/include -IC:/repos/esp-idf/components/efuse/include -IC:/repos/esp-idf/components/efuse/esp32/include -IC:/repos/esp-idf/components/vfs/include -IC:/repos/esp-idf/components/esp_wifi/include -IC:/repos/esp-idf/components/esp_wifi/esp32/include -IC:/repos/esp-idf/components/esp_event/include -IC:/repos/esp-idf/components/esp_netif/include -IC:/repos/esp-idf/components/esp_eth/include -IC:/repos/esp-idf/components/tcpip_adapter/include -IC:/repos/esp-idf/components/app_trace/include -I../components/STC3115_Drivers -I../components/Filters -I../components/ibNavSix -I../components/BME680 -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -std=gnu++11 -fno-exceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER=\"v4.1-dirty\" -DESP_PLATFORM -MD -MT esp-idf/main/CMakeFiles/__idf_main.dir/main.cpp.obj -MF esp-idf\main\CMakeFiles\__idf_main.dir\main.cpp.obj.d -o esp-idf/main/CMakeFiles/__idf_main.dir/main.cpp.obj -c ../main/main.cpp
In file included from ../main/main.h:11,
from ../main/main.cpp:8:
../components/ibNavSix/ibNavSixInitialization.h:7:10: fatal error: ICM_20948.h: No such file or directory
#include "ICM_20948.h"
^~~~~~~~~~~~~

Re: #include gives no such file or directory (IDFGH-4287)

Posted: Tue Dec 01, 2020 5:03 pm
by veelox
up, still havent been able to figure out why

Re: #include gives no such file or directory (IDFGH-4287)

Posted: Wed Dec 02, 2020 6:45 am
by ESP_Angus
Hi veelox,

It looks like the CMakeLists.txt file in the ICM_20948 directory doesn't have any "INCLUDE_DIRS ." clause inside it. So this directory is not added to the include search path.

(The compiler will always allow a source file in the same directory to include a header inside that directory, even without the right search path. Which is why ICM_20948.cpp can compile OK, but files in other directories can't see this header.)

Angus