Page 1 of 1

custom components and include files

Posted: Sun Mar 05, 2017 10:44 am
by kurtzweber
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!

Re: custom components and include files

Posted: Sun Mar 05, 2017 4:41 pm
by kolban
In your example, have you create a file called "component.mk" in your "component1" folder? If so, what is in it?

Re: custom components and include files

Posted: Sun Mar 05, 2017 7:31 pm
by kurtzweber
Hi!

yes, initially it was empty (and it didn't work)... I tried adding the following line:

Code: Select all

COMPONENT_ADD_INCLUDEDIRS := include
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:

Code: Select all

# By default, include only the include/ dir.
COMPONENT_ADD_INCLUDEDIRS = include

Re: custom components and include files

Posted: Mon Mar 13, 2017 8:12 am
by ESP_Angus
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

Re: custom components and include files

Posted: Thu Jul 13, 2017 3:02 pm
by js1234
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)

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 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?

Re: custom components and include files

Posted: Thu Jul 13, 2017 3:15 pm
by js1234
I found my mistake...

I need to include "MdnsHandler.h" not "MDNSHandler.h"

Re: custom components and include files

Posted: Thu Mar 04, 2021 12:59 pm
by ksnboopa
I have come across the same issue, got it sorted using this video.
It may help anyone https://youtu.be/RAdvZw00wRk