Page 1 of 1
Unable to include Library
Posted: Mon Jan 18, 2021 5:05 pm
by DutchOrange
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
Re: Unable to include Library
Posted: Tue Jan 19, 2021 1:47 am
by ESP_Sprite
Do you have a led_strip.h, and if so, where is it located?
Re: Unable to include Library
Posted: Tue Jan 19, 2021 4:29 pm
by DutchOrange
Here is the full path to it
E:\Desktop\MDF\esp-mdf\esp-idf-lib\components\led_strip
Re: Unable to include Library
Posted: Tue Jan 19, 2021 5:21 pm
by GustavoGB
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
)
Re: Unable to include Library
Posted: Wed Jan 20, 2021 5:25 am
by ESP_Sprite
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?
Re: Unable to include Library
Posted: Fri Jan 22, 2021 5:41 am
by DutchOrange
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
Re: Unable to include Library
Posted: Mon Jan 25, 2021 5:17 pm
by DutchOrange
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 ?
Re: Unable to include Library
Posted: Fri Jan 29, 2021 3:11 pm
by GustavoGB
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.
Re: Unable to include Library
Posted: Fri Jan 29, 2021 7:45 pm
by DutchOrange
Thank you, It seems to have worked perfectly.
Re: Unable to include Library
Posted: Wed Jul 12, 2023 6:06 pm
by AnmolSinghShekhawat
This worked for me
just add the following line in CMakeLists.txt
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/led_strip)
It looks something like this
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/led_strip)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(hello_world)