in0
October 7, 2021, 11:07pm
3
Unfortunately, the Arduino IDE does not provide for this. There have been some feature requests for it. This one would probably be the most interesting:
opened 06:01PM - 04 Jul 18 UTC
type: enhancement
topic: code
### Describe the request
🙂 It will be easier for sketch developers to share a… sketch as a package that includes library dependencies, avoiding the need for each user to install the library dependencies.
🙂 Library dependencies of the sketch can be controlled, allowing them to be pinned to the specific versions the sketch was intended to be used with, independent from the version of any globally installations of the library. As an example there are major changes to the API of the very popular "**ArduinoJson**" library in version 6 and sketches only work with one or the other major version series of that dependency.
### Describe the current behavior
The common approach to bundling libraries with a sketch is to dump the library code files into the sketch root folder.
### Arduino CLI version
a58d5adbe269ecc55778c007dc8ac39ffd42ce85
### Operating system
All
### Operating system version
All
### Additional context
1. As a workaround in the preferences the sketchbook location ([`directories.user`](https://arduino.github.io/arduino-cli/dev/configuration/#configuration-keys)) can be set to the sketch folder. But this has to be done manually and changed every time another program is handled. So there could be some option for this to be set in the `.ino` file.
2. In the build folder a file `build.options.json` is generated automatically.
There are some options where additional library folders could possibly be added?
E.g.:
- builtInLibrariesFolders
- otherLibrariesFolders
#### Additional Requests
- https://github.com/arduino/arduino-ide/issues/150#issuecomment-830714850
- https://github.com/arduino/arduino-cli/issues/1255#issuecomment-568900798
- https://github.com/arduino/arduino-cli/issues/1255#issuecomment-671084645
- https://github.com/arduino/arduino-cli/issues/1255#issuecomment-751318119
- https://github.com/arduino/arduino-cli/issues/1255#issuecomment-750951958
- https://forum.arduino.cc/t/how-do-i-include-a-library-in-a-sketch-directory/1079812
- https://forum.arduino.cc/t/arduino-ide-cant-find-local-custom-libraries-in-relative-path/669421
- https://forum.arduino.cc/t/suggestion-improve-library-manager/847666
- https://forum.arduino.cc/t/using-generated-headers/912691
### Issue checklist
- [X] I searched for previous requests in [the issue tracker](https://github.com/arduino/arduino-cli/issues?q=)
- [X] I verified the feature was still missing when using the latest [nightly build](https://arduino.github.io/arduino-cli/dev/installation/#nightly-builds)
- [X] My request contains all necessary details
(Arduino CLI provides the build system for all the official Arduino development software, so a feature implemented there propagates to all the tools)
Arduino CLI does provide a arduino-cli compile --library <library path> flag you can use to specify additional library folders:
So if you don't mind using a command line tool that would probably help you out.
Another option might be to store the library in the sketch folder, but install it in the standard libraries folder via a symlink.
By the way, are you aware of this project?