Where are Arduino Standard Libraries?

Greetings,

I wish to use VSCode and PlatformIO for Arduino development. I don’t want to install the Arduino IDE; because I don’t like where the core libraries are stored.

I would prefer to retrieve these libraries from GitHub to a local location of my choice.

Can someone tell me where I find the libraries? I see Arduino in GitHub (Arduino · GitHub) but don’t know which repository has the core with files such as (Arduino.h).

Thank you!

Well, to answer that question, you’d need to say what architecture you’re developing for. As you have both the core board files, and architecture specific libraries distributed with it as well.

e.g.
AVR (Arduino Uno, etc) is in GitHub - arduino/ArduinoCore-avr: The Official Arduino AVR core
SAM (Arduino Due, etc) is in GitHub - arduino/ArduinoCore-samd: Arduino Core for SAMD21 CPU

As far as other Arduino libraries, I’m not exactly sure.

However, that really isn’t going to help you much since PlatformIO provides it’s own packaged version of those, as well as splitting stuff up between frameworks and platforms to allow for Windows/MAC/Linux/x86/x64/ARM/ARM64 etc. Nor does it let you take the most advantage of PlatformIO. Instead, either go to PlatformIO Registry or use the ‘Libraries’ view in the built in PlatformIO Home, and search for the library you want. Once you find it, you can either click on the repository link on the right side, and there you have it… the source repository. Or, you can just add the name of the library (or ID) to your projects platformio.ini lib_deps line and you’re set. As far as controlling where is saved locally, I’ve never tried it, but there are a couple of environment variables that were introduced in v4.0 that should let you control it quite easily

e.g PLATFORMIO_CORE_DIR sets the main PlatformIO working directory… everything will be installed under this directory. PLATFORMIO_PLATFORMS_DIR lets you set the directory platform related files will go. PLATFORMIO_PACKAGES_DIR controls where toolchains, SDKs, upload/debug tools, etc go.

Hopefully that gives you some ideas, or confuses you even more! :laughing: If that wasn’t quite what you were after, try try again! :wink:

1 Like

Thank you Peter.

I’m starting with AVR on Windows, with VSCode/PlatformIO.

So here’s the scenario I’m running into. I’m writing some articles on Arduino development and am doing so for both the native Arduino IDE and VSCode/PlatformIO. I’m noticing many on github are doing this so I want to do the same.

One potential issue I see with using the (Arduino IDE) installed cores is the location. By looking at the Arduino IDE install location, the IDE version is included in the directory structure.
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.33.0_x86__mdqgnx93n4wtt
That folder structure changes when the Arduino IDE is updated. Well… having to update a project’s library location each time I update the Arduino IDE isn’t something I want to deal with.

This all started when I tried to compile a simple example in VSCode/PlatformIO. First thing the compiler complained about not knowing where Arduino.h is.

I would prefer to use all of the PlatformIO features. However, I would like my code to use the same core files and libraries for both Arduino IDE and VSCode/PlatformIO environments. Is this possible or do I just leave it alone?

Thanks again!

It looks like two things are mixed up here. Unless you have a really strange platformio.ini file, Arduino.h will always be found when building the firmware, i.e. when running the build task.

However, IntelliSense (the red squiggly lines) often has hickups and complains that it can’t find Arduino.h and shows the red squiggly lines. Search in this forum for instructions how to fix it.

If you plan to publish articles on Arduino development, I would recommend that you use the latest versions of both the Arduino IDE and PlatformIO. Otherwise your readers will have difficulties following along.

From time to time, they will use slightly different versions of the Arduino core libraries. But the differences are usually minor and if the your code doesn’t build or run anymore, it should be straightforward to adapt it.

Similar reasining applies to third-party libraries, which are very relevant for real world projects. You probably want to go with the latest version as readers are unlikely to install old versions. In the Arudino IDE, there is a single location for libraries. Updating the library updates it for all projects, possibly breaking some of them. In PlatformIO, each project uses its own copy of third-party libraries. Depending on how you declare it in platformio.ini, the version can be frozen.

1 Like

Thank you Manuel.

I haven’t updated the platformio.ini at all; it’s a new install. I’ll keep everything separate as suggested. But my simple blink test won’t compile because Arduino.h can’t be found. I’d like to focus on that issue first. Doing so will probably give me a better idea of how its configured. I’ll search the forum as suggested.

As for Arduino IDE development, I also include 3rd party libraries along with my project. When I publish my articles, I don’t make mention where I store libraries because it shouldn’t matter.

Thank you again,
Bob

If the Arduino.h problem really affects building the firmware (and not just IntelliSense), then you get a detailed error message in the TERMINAL view. If so, post the full build log from that view here.

As for third-party libraries: You don’t need to mention where the libraries need to be installed, but you need to mentioned what libraries need to be installed. In PlatformIO, that’s not needed as it is declared in platformio.ini.

1 Like

I’ve got it all working now, thank you for all your input. In the end, attempting to use a set of common core and library files for both development in Arduino IDE and VSCode/PlatformIO requires more configuration work than I’m willing to do.

Thank you again!

Bob

1 Like

Is this when you install via the Windows Store, rather than via the installer or zip file from arduino.cc’s download page? As that would explain the odd path, and it changing per IDE version. As normally you’d find the various install cores in %localappdata%\Arduino15\packages, and the paths shouldn’t change drastically.

I doubt that will would work without major, major configuration changes and trickery on your part to disable a lot of PlatformIOs core design smarts in trying to make it so you don’t need to think about the platform/framework/core/compiler/toolchain installation and configuration.

Using a common library folder is a different matter entirely… you can quite easily point PlatformIO to where you have your Arduino common libraries folder, but there’s not much point in most cases. Better to use PlatformIO’s concept of ‘per project’ libraries, so you can also make use of version locking, and automatic library installation, etc.

bobmixon idk if you still need this but here is where the arduino core is located on my computer ill put it anyway to help people that stumble across the thread like i did looking for the arduino libraries its path is C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino