custom components and include files

kurtzweber
Posts: 64
Joined: Tue Jan 10, 2017 1:09 pm

custom components and include files

Postby kurtzweber » Sun Mar 05, 2017 10:44 am

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!

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: custom components and include files

Postby kolban » Sun Mar 05, 2017 4:41 pm

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

kurtzweber
Posts: 64
Joined: Tue Jan 10, 2017 1:09 pm

Re: custom components and include files

Postby kurtzweber » Sun Mar 05, 2017 7:31 pm

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

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: custom components and include files

Postby ESP_Angus » Mon Mar 13, 2017 8:12 am

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

js1234
Posts: 18
Joined: Thu Jan 26, 2017 1:16 pm

Re: custom components and include files

Postby js1234 » Thu Jul 13, 2017 3:02 pm

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?

js1234
Posts: 18
Joined: Thu Jan 26, 2017 1:16 pm

Re: custom components and include files

Postby js1234 » Thu Jul 13, 2017 3:15 pm

I found my mistake...

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

ksnboopa
Posts: 9
Joined: Sun May 03, 2020 3:19 pm

Re: custom components and include files

Postby ksnboopa » Thu Mar 04, 2021 12:59 pm

I have come across the same issue, got it sorted using this video.
It may help anyone https://youtu.be/RAdvZw00wRk

Who is online

Users browsing this forum: Bing [Bot] and 76 guests