Include component header

BinaryPoet
Posts: 9
Joined: Thu Aug 31, 2023 1:01 pm

Include component header

Postby BinaryPoet » Tue May 14, 2024 4:00 pm

Hello,
I started a new project using the "ledc_basic_example" template. The main includes "driver/ledc.h" end everything build fine.
Then I added a component. I include the component header, let say "mycomponent.h" into the main, but when compiling this header is not found. So I changed the CMakeLists.txt placed into "led_basic/main/" folder to include my component.
As described in a previous thread I tried both

Code: Select all

idf_component_register(SRCS "main.c"
                  INCLUDE_DIRS "."
                  PRIV_REQUIRES my_component) 
and

Code: Select all

set(includedirs
  ../components/my_component/include/
  "."    # this line is probably not needed since main dir is included by default and there are no sub-directories under main
  )

idf_component_register(SRCS "main.c"
                    INCLUDE_DIRS ${includedirs} 
                    PRIV_REQUIRES my_component)
At this point the driver/ledc.h is not found.
Why?

ESP_Sprite
Posts: 9724
Joined: Thu Nov 26, 2015 4:08 am

Re: Include component header

Postby ESP_Sprite » Tue May 14, 2024 11:53 pm

The 'main' component implicitly REQUIREs all components; your new component does not. You probably want to add "driver" to PRIV_REQUIRES.

Who is online

Users browsing this forum: No registered users and 99 guests