Skip to content
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

Detect libraries in Sketch Folder #2763

Closed
3 tasks done
fedy0 opened this issue Nov 22, 2024 · 4 comments
Closed
3 tasks done

Detect libraries in Sketch Folder #2763

fedy0 opened this issue Nov 22, 2024 · 4 comments
Assignees
Labels
conclusion: duplicate Has already been submitted topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@fedy0
Copy link

fedy0 commented Nov 22, 2024

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
@fedy0 fedy0 added the type: enhancement Proposed improvement label Nov 22, 2024
@fedy0
Copy link
Author

fedy0 commented Nov 22, 2024

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

@per1234 per1234 self-assigned this Nov 22, 2024
@per1234
Copy link
Contributor

per1234 commented Nov 22, 2024

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.

@per1234 per1234 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2024
@per1234 per1234 added conclusion: duplicate Has already been submitted topic: code Related to content of the project itself topic: build-process Related to the sketch build process labels Nov 22, 2024
@fedy0
Copy link
Author

fedy0 commented Nov 26, 2024

Hi

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

Nevertheless, thank you for your prompt response.

@per1234
Copy link
Contributor

per1234 commented Nov 26, 2024

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
Labels
conclusion: duplicate Has already been submitted topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

2 participants