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

veelox
Posts: 16
Joined: Tue Nov 03, 2020 4:21 pm

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

Postby veelox » Wed Nov 18, 2020 6:10 pm

Hi, my project tree look like this

TOP LEVEL FOLDER:
- main folder
- component folder
- CMakeLists.txt with :

Code: Untitled.cmake Select all

 
cmake_minimum_required(VERSION 3.5)
set(SUPPORTED_TARGETS esp32)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(FirmwareRTOS)

MAIN FOLDER :
- main.cpp
- main.h
- component.mk (empty)
- CMakeLists.txt :

Code: Untitled.cmake Select all


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 :

Code: Untitled.cmake Select all


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 :

Code: Untitled.cmake Select all


idf_component_register(SRCS "sensor.cpp" "sensorInit.cpp" "sensorRoutine.cpp" INCLUDE_DIRS ".")

Inside sensorInit.h there is

Code: Untitled.cpp Select all


#include "stc3115_Driver.h"
i get the following error :

Code: Untitled.cpp Select all


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 :

Code: Untitled.cmake Select all


COMPONENT_SRCDIRS := .
COMPONENT_ADD_INCLUDEDIRS := include/
No success

Angus
Espressif staff
Espressif staff
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: #include gives no such file or directory

Postby Angus » Wed Nov 18, 2020 11:48 pm

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

veelox
Posts: 16
Joined: Tue Nov 03, 2020 4:21 pm

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

Postby veelox » 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>?

Angus
Espressif staff
Espressif staff
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

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

Postby Angus » Thu Nov 19, 2020 11:43 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.

veelox
Posts: 16
Joined: Tue Nov 03, 2020 4:21 pm

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

Postby veelox » Thu Nov 26, 2020 4:09 pm

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

Angus
Espressif staff
Espressif staff
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

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

Postby Angus » Thu Nov 26, 2020 9:00 pm

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.

veelox
Posts: 16
Joined: Tue Nov 03, 2020 4:21 pm

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

Postby veelox » Fri Nov 27, 2020 1:59 pm

MAIN FOLDER
- main.cpp/main.h
- CMakeLists.txt :

Code: Untitled.cmake Select all


idf_component_register(SRCS "main.cpp"
INCLUDE_DIRS "."
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 :

Code: Untitled.cmake Select all


idf_component_register(SRCS 
"filters.cpp"
INCLUDE_DIRS ".")
ICM_20948 FOLDER
- ICM_20948.cpp/.h
- ICM_20948_C.c/.h
- CMakeLists.txt :

Code: Untitled.cmake Select all


idf_component_register(SRCS 
"ICM_20948.cpp"
"ICM_20948_C.c"
REQUIRES driver)
IBNAVSIX FOLDER
- ibNavSixInitialization.cpp/.h
- ibNavRoutine.cpp/.h
- CMakeLists.txt :

Code: Untitled.cmake Select all


idf_component_register(SRCS 
"ibNavSixInitialization.cpp"
"ibNavRoutine.cpp"
INCLUDE_DIRS "."
REQUIRES ICM_20948 STC3115_Drivers Filters driver esp32 BME680)
in my ibNavSixInitialisation.h :

Code: Untitled.cpp Select all


#include "stc3115_Driver.h"
#include "filters.cpp"
#include "bme680.h" //From another component folder
#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"
^~~~~~~~~~~~~

veelox
Posts: 16
Joined: Tue Nov 03, 2020 4:21 pm

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

Postby veelox » Tue Dec 01, 2020 5:03 pm

up, still havent been able to figure out why

Angus
Espressif staff
Espressif staff
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

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

Postby Angus » Wed Dec 02, 2020 6:45 am

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

Who is online

Users browsing this forum: No registered users and 6 guests