Skip to content

Detect libraries in Sketch Folder #2763

Not planned
Not planned
@fedy0

Description

@fedy0

Describe the request

The sketch folder structure described in the arduino-cli documentation does not work (i.e. the libraries added in the sketch folder can not be found by both the arduino-cli and the arduino-builder
Image

Describe the current behavior

It returns the error below when one tries to compile a sketch with a library whose location is within the sketch folder itself

> fatal error: SomeLib.h: No such file or directory

Arduino CLI version

1.1.1

Operating system

Linux

Operating system version

24.04

Additional context

If the build procedure can be made in such a way that the build process (both the cli & builder) checks the sketch folder for libraries first before the Arduino/libraries and /home/<user>/.arduino15/packages/<platform>/hardware/<core>/<version>/libraries locations that would be great and in adherence to the sketch folder structure specification

Issue checklist

  • I searched for previous requests in the issue tracker
    I verified the feature was still missing when using the nightly build
    My request contains all necessary details

Activity

fedy0

fedy0 commented on Nov 22, 2024

@fedy0
Author

Additionally, this feature can also be added in sketch.yaml file as show below. This will enable the addition of third party libraries or self developed libraries.

profiles:
  <PROFILE_NAME>:
    notes: <USER_NOTES>
    fqbn: <FQBN>
    programmer: <PROGRAMMER>
    platforms:
      - platform: <PLATFORM> (<PLATFORM_VERSION>)
        platform_index_url: <3RD_PARTY_PLATFORM_URL>
      - platform: <PLATFORM_DEPENDENCY> (<PLATFORM_DEPENDENCY_VERSION>)
        platform_index_url: <3RD_PARTY_PLATFORM_DEPENDENCY_URL>
    libraries:
      - <LIB_NAME> (<LIB_VERSION>)
      - <LIB_NAME> (<LIB_VERSION>)
        library_url: <3RD_PARTY_LIBRARY_DEPENDENCY_URL>
      - <LIB_NAME> (<LIB_VERSION>)
        library_url: <3RD_PARTY_LIBRARY_DEPENDENCY_URL>
    port: <PORT_NAME>
    port_config:
      <PORT_SETTING_NAME>: <PORT_SETTING_VALUE>
      ...
    protocol: <PORT_PROTOCOL>
  ...more profiles here...
self-assigned this
on Nov 22, 2024
per1234

per1234 commented on Nov 22, 2024

@per1234
Contributor

Hi @fedy0.

fatal error: SomeLib.h: No such file or directory

Even though the example in the specification shows the common use case of bundling a library's files with a sketch, the files in the src subfolder of the sketch are not treated as libraries. They are only additional files of the sketch. For this reason, you must use the relative path to the file in the #include directive. In the example shown in the specification, if you wanted to add an #include directive for SomeLib.h to Foo.ino, it would look like this:

#include "src/SomeLib/src/SomeLib.h"

the build procedure can be made in such a way that the build process (both the cli & builder) checks the sketch folder for libraries

I see we have another request for this feature at #1255.

this feature can also be added in sketch.yaml file as show below

I see we have another request for this feature at #2133

It is best to have only a single issue per subject so we can consolidate all relevant discussion to one place, so I'll go ahead and close this in favor of the previous feature requests.

fedy0

fedy0 commented on Nov 26, 2024

@fedy0
Author

Hi

The relative path doesn't work that's why I opened this request.

Nevertheless, thank you for your prompt response.

per1234

per1234 commented on Nov 26, 2024

@per1234
Contributor

The relative path doesn't work

It works just fine for me, and for the many other users who use this feature. So I suspect user error. If you post over on Arduino forum I'm certain we will be able to help you get it working:

https://forum.arduino.cc/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @per1234@fedy0

      Issue actions

        Detect libraries in Sketch Folder · Issue #2763 · arduino/arduino-cli