Skip to content

Recommended method to add Arduino libraries using arduino-eps32 as component to esp-idf #1449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
PreferHardware opened this issue May 30, 2018 · 11 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@PreferHardware
Copy link

Using arduino-esp32 as a component to esp-idf in Eclipse seems to work well. I installed it exactly as the README suggests and it compiled first time.

What is the recommended way to add Arduino libraries and ensure that make knows what to do with them?

Many thanks.

@copercini
Copy link
Contributor

I'm not sure what is the better way, but the easier way is just put your libs on ProjectFolder\components\arduino\libraries and that's all

@PreferHardware
Copy link
Author

Thanks, that works. I was hoping that there was an established method to include libraries, but keeping them separate from the arduino core.

@lbernstone
Copy link
Contributor

You can softlink in order to keep some logical separation. git won't complain quite as much. Eclipse may have some other way to include directories into your project.

@dannybackx
Copy link

dannybackx commented Jul 17, 2018

I tried several of the variables described in the documentation (chapter 4 "API Guides" -> "Using the Build System" if you look at the pdf).
I've added several arduino libraries as libraries/ so libraries/TFT_eSPI , libraries/pubsubclient etc .
I'm looking for a way to :

  • get that to work
  • make their build use include files from main/

This would keep things much more nicely separated ....

Does anyone know how to do this ?

Workarounds like
ln -s pwd/libraries/* components/arduino/libraries
are possible but not clean

@me-no-dev
Copy link
Member

you can add the libs to your components folder and then add one file in each lib so the build will pick them up. Here is an example that has the source files in src folder (adjust as necessary) https://github.com/me-no-dev/AsyncTCP/blob/master/component.mk

@dannybackx
Copy link

Thanks.
More trial and error got me with this (main/component.mk) which appears to work.
Anything I'm still doing wrong ?

COMPONENT_SRCDIRS += libraries \
        libraries/TFT_eSPI \
        libraries/arduinojson \
        libraries/pubsubclient \
        libraries/pubsubclient/src \
        libraries/rcswitch \
        libraries/rfid \
        libraries/TFT_eSPI \
        libraries/Timezone \
        main .

COMPONENT_ADD_INCLUDEDIRS := libraries \
        libraries/arduinojson \
        libraries/pubsubclient \
        libraries/pubsubclient/src \
        libraries/rcswitch \
        libraries/rfid \
        libraries/TFT_eSPI \
        libraries/Timezone \
        main .

@Tuet
Copy link

Tuet commented Jul 26, 2018

Hi,
I added a libraries folder below the main folder and copied the libraries in it. Then I populated the main/component.mk with the following below to add all library contents (all source files in library main folder and all source files in library/src/ and all sub-folders of library/src/).

ARDUINO_ULIBRARIES_LIST := $(patsubst $(COMPONENT_PATH)/libraries/%,%,$(wildcard $(COMPONENT_PATH)/libraries/*))
ARDUINO_SINGLE_ULIBRARY_FILES = $(patsubst $(COMPONENT_PATH)/%,%,$(sort $(dir $(wildcard $(COMPONENT_PATH)/libraries/$(MODULE)/*)) $(dir $(wildcard $(COMPONENT_PATH)/libraries/$(MODULE)/src/*/)) $(dir $(wildcard $(COMPONENT_PATH)/libraries/$(MODULE)/src/*/*/)) $(dir $(wildcard $(COMPONENT_PATH)/libraries/$(MODULE)/src/*/*/*/)) $(dir $(wildcard $(COMPONENT_PATH)/libraries/$(MODULE)/src/*/*/*/*/))))
ARDUINO_USER_LIBS := $(foreach MODULE,$(ARDUINO_ULIBRARIES_LIST), $(ARDUINO_SINGLE_ULIBRARY_FILES))

COMPONENT_ADD_INCLUDEDIRS := $(ARDUINO_USER_LIBS) main .
COMPONENT_SRCDIRS := $(ARDUINO_USER_LIBS) main .

For me this works for standard Arduino libraries. I derived this from the component.mk of the arduino-folder.

Please let us know if this works for you as well!

@stale
Copy link

stale bot commented Aug 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Aug 1, 2019
@stale
Copy link

stale bot commented Aug 15, 2019

This stale issue has been automatically closed. Thank you for your contributions.

@allex1978
Copy link
Contributor

апаук

Hi,
I added a libraries folder below the main folder and copied the libraries in it. Then I populated the main/component.mk with the following below to add all library contents (all source files in library main folder and all source files in library/src/ and all sub-folders of library/src/).

ARDUINO_ULIBRARIES_LIST := $(patsubst $(COMPONENT_PATH)/libraries/%,%,$(wildcard $(COMPONENT_PATH)/libraries/*))
ARDUINO_SINGLE_ULIBRARY_FILES = $(patsubst $(COMPONENT_PATH)/%,%,$(sort $(dir $(wildcard $(COMPONENT_PATH)/libraries/$(MODULE)/*)) $(dir $(wildcard $(COMPONENT_PATH)/libraries/$(MODULE)/src/*/)) $(dir $(wildcard $(COMPONENT_PATH)/libraries/$(MODULE)/src/*/*/)) $(dir $(wildcard $(COMPONENT_PATH)/libraries/$(MODULE)/src/*/*/*/)) $(dir $(wildcard $(COMPONENT_PATH)/libraries/$(MODULE)/src/*/*/*/*/))))
ARDUINO_USER_LIBS := $(foreach MODULE,$(ARDUINO_ULIBRARIES_LIST), $(ARDUINO_SINGLE_ULIBRARY_FILES))

COMPONENT_ADD_INCLUDEDIRS := $(ARDUINO_USER_LIBS) main .
COMPONENT_SRCDIRS := $(ARDUINO_USER_LIBS) main .

For me this works for standard Arduino libraries. I derived this from the component.mk of the arduino-folder.

Please let us know if this works for you as well!

Hi, this method not working now. How to use something similar with cmake ?

@jarusRnD
Copy link

jarusRnD commented Mar 3, 2020

hi everyone
I also have this problem
what I have did
git clone > esp-idf v4.0
git clone > Arduino esp32 v4.0
and the rest of the process same as shown in the official guide.

now I want to add some Arduino another library in my Arduino component library
if I give absolute file location in include declaration than it's work.
but in esp idf 3.2.2 it happens automatically

sorry for my English.
thanks for your effort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

8 participants