Unable to include Library

DutchOrange
Posts: 74
Joined: Fri Dec 04, 2020 4:23 pm

Unable to include Library

Postby DutchOrange » Mon Jan 18, 2021 5:05 pm

So I was trying to include the "led_strip.h" Libary but I just cant get it working. Alsways getting the error:
../main/Reciver.c:14:10: fatal error: led_strip.h: No such file or directory
#include "led_strip.h"
Here is my CMmake in the project folder:

Code: Select all

# The following four lines of boilerplate have to be in your project's CMakeLists From Reviver 
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)   

set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/esp-idf-lib/components)
#set(EXTRA_COMPONENT_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../components)


include($ENV{MDF_PATH}/project.cmake)
#include($ENV{IDF_PATH}/tools/cmake/project.cmake)


project(Node_reciver)
And here is the CMake in the main folder:

Code: Select all

idf_component_register(SRCS "Reciver.c"
                    INCLUDE_DIRS "."
		    REQUIRES mcommon mconfig mwifi mlink
)
Any ideas what else ?
Thanks

ESP-IDF 4.1 On Windows 10

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

Re: Unable to include Library

Postby ESP_Sprite » Tue Jan 19, 2021 1:47 am

Do you have a led_strip.h, and if so, where is it located?

DutchOrange
Posts: 74
Joined: Fri Dec 04, 2020 4:23 pm

Re: Unable to include Library

Postby DutchOrange » Tue Jan 19, 2021 4:29 pm

Here is the full path to it
E:\Desktop\MDF\esp-mdf\esp-idf-lib\components\led_strip

GustavoGB
Posts: 18
Joined: Fri Jan 15, 2021 1:46 am

Re: Unable to include Library

Postby GustavoGB » Tue Jan 19, 2021 5:21 pm

The best option is to put the "led_strip.h" file in the same folder where your main file ("Reciver.c" in your case) is located.

If the "led_strip.h" file is linked with a "led_strip.c" file, you must copy them both, and the CMake file would be as follows:

Code: Select all

idf_component_register(SRCS "Reciver.c"
                            "led_strip.c"
                    INCLUDE_DIRS "."
		    REQUIRES mcommon mconfig mwifi mlink
)

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

Re: Unable to include Library

Postby ESP_Sprite » Wed Jan 20, 2021 5:25 am

DutchOrange wrote:
Tue Jan 19, 2021 4:29 pm
Here is the full path to it
E:\Desktop\MDF\esp-mdf\esp-idf-lib\components\led_strip
Thanks, so you're effectively making the led_strip thing into a component. Do you also have a CMakeLists.txt in that directory? If so, can you post its contents?

DutchOrange
Posts: 74
Joined: Fri Dec 04, 2020 4:23 pm

Re: Unable to include Library

Postby DutchOrange » Fri Jan 22, 2021 5:41 am

So here is the CmakeList in " E:\Desktop\MDF\esp-mdf\esp-idf-lib\components\led_strip " Directory

Code: Select all

idf_component_register(
    SRCS "led_strip.c"
    INCLUDE_DIRS .
    REQUIRES log esp_idf_lib_helpers
)
Also a bit off topic but what is the difference of

Code: Select all

INCLUDE_DIRS .
INCLUDE_DIRS "."
INCLUDE_DIRS " "
Thanks for the help

DutchOrange
Posts: 74
Joined: Fri Dec 04, 2020 4:23 pm

Re: Unable to include Library

Postby DutchOrange » Mon Jan 25, 2021 5:17 pm

GustavoGB wrote:
Tue Jan 19, 2021 5:21 pm
The best option is to put the "led_strip.h" file in the same folder where your main file ("Reciver.c" in your case) is located.

If the "led_strip.h" file is linked with a "led_strip.c" file, you must copy them both, and the CMake file would be as follows:

Code: Select all

idf_component_register(SRCS "Reciver.c"
                            "led_strip.c"
                    INCLUDE_DIRS "."
		    REQUIRES mcommon mconfig mwifi mlink
)
Would that go into the "main" folder ? and wouldn't it need anything more / How would I link it ?

GustavoGB
Posts: 18
Joined: Fri Jan 15, 2021 1:46 am

Re: Unable to include Library

Postby GustavoGB » Fri Jan 29, 2021 3:11 pm

DutchOrange wrote:
Mon Jan 25, 2021 5:17 pm
GustavoGB wrote:
Tue Jan 19, 2021 5:21 pm
The best option is to put the "led_strip.h" file in the same folder where your main file ("Reciver.c" in your case) is located.

If the "led_strip.h" file is linked with a "led_strip.c" file, you must copy them both, and the CMake file would be as follows:

Code: Select all

idf_component_register(SRCS "Reciver.c"
                            "led_strip.c"
                    INCLUDE_DIRS "."
		    REQUIRES mcommon mconfig mwifi mlink
)
Would that go into the "main" folder ? and wouldn't it need anything more / How would I link it ?
As you have said, you have already put #include "led_strip.h" in your main code.
So you only need to put led_strip.h and led_strip.c in the same folder where you have the main code. And do that little modification in the CMake file.
It should work.

DutchOrange
Posts: 74
Joined: Fri Dec 04, 2020 4:23 pm

Re: Unable to include Library

Postby DutchOrange » Fri Jan 29, 2021 7:45 pm

Thank you, It seems to have worked perfectly.

AnmolSinghShekhawat
Posts: 1
Joined: Wed Jul 12, 2023 6:00 pm

Re: Unable to include Library

Postby AnmolSinghShekhawat » Wed Jul 12, 2023 6:06 pm

This worked for me

just add the following line in CMakeLists.txt
  1. set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/led_strip)
It looks something like this
  1. # The following lines of boilerplate have to be in your project's
  2. # CMakeLists in this exact order for cmake to work correctly
  3. cmake_minimum_required(VERSION 3.5)
  4.  
  5. set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/led_strip)
  6.  
  7. include($ENV{IDF_PATH}/tools/cmake/project.cmake)
  8. project(hello_world)

Who is online

Users browsing this forum: No registered users and 104 guests