Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Option to add costum libraries to project folder #1341

Open
Yorams opened this issue Sep 6, 2021 · 3 comments
Open

Option to add costum libraries to project folder #1341

Yorams opened this issue Sep 6, 2021 · 3 comments

Comments

@Yorams
Copy link

Yorams commented Sep 6, 2021

I want to have a .libraries folder with my own costum libraries. Right now the compiler cannot find the libraries, even if they are in the includePath of c_cpp_properties.json

The option talked about in this issue is what i mean: #830. But is is closed by a bot. The only way to add costum libraries is to copy them in the default libraries folder. And that is not a good workflow.

@barreiroleo
Copy link

In IDE versions higher than 1.6 if you want to include libraries from the project folder, you need to put them in a src subfolder. For example:
#include "src/YourLib/YourLib.h"

@sahlex
Copy link

sahlex commented Sep 8, 2022

This does not solve the problem, barreiroleo. As suggested in the online docs of arduino-cli (https://arduino.github.io/arduino-cli/0.27/sketch-build-process/), any library contained in a subfolder src should be referencable. But if this library (e.g. ArduinoBearSSL) contains subfolders that have headers referenced with <bearssl/bearssl_hash.h> the build breaks nevertheless. So this approach works for self-contained files but not for libraries having a complex directory structure (like ArduinoBearSSL does).

However, there is a workaround: putting the libraries in a folder named libs (for instance), and writing a tasks.json that passes the libs directory with --libraries as an argument to arduino-cli works as intended. But this is cumbersome because the 'Verify'-button is no longer usable, only the task will do.

If the arduino extension would have an option for configuration of the --library flag, the problem would be solved. An even better approach would be if arduino-cli would handle the imports correctly - but that's out of scope for here.

@barreiroleo
Copy link

It depends on your approach. The Libs folder is generally used for third party packages. Placing your own files in the src folder gives you the ability to work on your packages without rewriting Cflags. I've been experiencing issues with the vscode extension overwriting my declarations. I no longer work with vscode and neither with Arduino framework, I don't know about the state of the art today.
Cheers

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants