Hello!
I'm trying to develop a custom, reusable component as described in:
https://github.com/espressif/esp-idf/bl ... system.rst
my project has the following folder structure:
/ (project root)
/main <- source code of my "main"
/components
/components/component1 <- source code of my component
/components/component1/include <- include files
when I try to include the header file in my main program, I always get a No such file or directory error. During the compile process, I see that the compiler correcly compile and link my custom component.
Based on the documentation, the compiler should automatically add the "include" subfolder to the search path:
A sub-directory "include" will be added to the global include search path for all other components.
where am I wrong?
Thanks!
custom components and include files
Re: custom components and include files
In your example, have you create a file called "component.mk" in your "component1" folder? If so, what is in it?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
-
- Posts: 64
- Joined: Tue Jan 10, 2017 1:09 pm
Re: custom components and include files
Hi!
yes, initially it was empty (and it didn't work)... I tried adding the following line:
and it worked! But I really can't understand why I had to explicitly add the include statement: in the component_wrapper.mk the line above is already present:
yes, initially it was empty (and it didn't work)... I tried adding the following line:
Code: Select all
COMPONENT_ADD_INCLUDEDIRS := include
Code: Select all
# By default, include only the include/ dir.
COMPONENT_ADD_INCLUDEDIRS = include
Re: custom components and include files
Hi Kurt,
Sorry for the slow reply. I'm not able to reproduce this (indeed we have a number of components in ESP-IDF where the component.mk file is just comments.) Perhaps the previous component.mk wasn't saved, or was saved at a different location?
If you or anyone else comes across this again please let us know, and we'll try to track it down.
Angus
Sorry for the slow reply. I'm not able to reproduce this (indeed we have a number of components in ESP-IDF where the component.mk file is just comments.) Perhaps the previous component.mk wasn't saved, or was saved at a different location?
If you or anyone else comes across this again please let us know, and we'll try to track it down.
Angus
Re: custom components and include files
Hello I have a similiar problem:
I have a project with following Makefile. The Components that I want to add to the project are in a different directory (see Makefile):
(I use libwebsockets as well)
In the wdk_middleware folder I have 2 folders named Communication and Utils.
In each there is a component.mk with COMPONENT_ADD_LDFLAGS=-lstdc++ -l$(COMPONENT_NAME)
and nothing else.
I have an include directory in the Communication folder with the Header file MDnsHandler,h
=> wdk_middleware/Communication/include
And the sourcefile MDnsHandler.cpp in the directory
wdk_middleware/Communication/
But I can't include the file MDnsHandler.h in my mainfile of the project, it just says:
fatal error: MDNSHandler.h: No such file or directory
It creates the Communication folder in the build directory of my project and also the MDnsHandler.d and MDnsHandler.o files.
So why does the project not know the include file?
I have a project with following Makefile. The Components that I want to add to the project are in a different directory (see Makefile):
(I use libwebsockets as well)
Code: Select all
#
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
# project subdirectory.
#
PROJECT_NAME := lws_server
EXTRA_COMPONENT_DIRS += ./components
EXTRA_COMPONENT_DIRS += $(PROJECT_PATH)/../../../../../wdk/trunc/wdk_middleware
# 0 = OTA Application, 1 = Factory (Recovery) Application
LWS_IS_FACTORY_APPLICATION=1
export LWS_IS_FACTORY_APPLICATION
export A
export F
include $(IDF_PATH)/make/project.mk
include sdkconfig
include ${PWD}/components/libwebsockets/scripts/esp32.mk
CFLAGS+= -I$(COMPONENT_PATH)/../components/libwebsockets/plugins \
-DLWS_IS_FACTORY_APPLICATION=$(LWS_IS_FACTORY_APPLICATION) \
-I$(IDF_PATH)/components/soc/esp32/include/ \
-I$(IDF_PATH)/components/esp32/include -Os
CXXFLAGS += -Os
export IDF_PATH
In each there is a component.mk with COMPONENT_ADD_LDFLAGS=-lstdc++ -l$(COMPONENT_NAME)
and nothing else.
I have an include directory in the Communication folder with the Header file MDnsHandler,h
=> wdk_middleware/Communication/include
And the sourcefile MDnsHandler.cpp in the directory
wdk_middleware/Communication/
But I can't include the file MDnsHandler.h in my mainfile of the project, it just says:
fatal error: MDNSHandler.h: No such file or directory
It creates the Communication folder in the build directory of my project and also the MDnsHandler.d and MDnsHandler.o files.
So why does the project not know the include file?
Re: custom components and include files
I found my mistake...
I need to include "MdnsHandler.h" not "MDNSHandler.h"
I need to include "MdnsHandler.h" not "MDNSHandler.h"
Re: custom components and include files
I have come across the same issue, got it sorted using this video.
It may help anyone https://youtu.be/RAdvZw00wRk
It may help anyone https://youtu.be/RAdvZw00wRk
Who is online
Users browsing this forum: No registered users and 188 guests