Adding header files to a project or library


How do we package include files with a project or library? Is there a better place to copy them than <user_folder>\AppData\Local\Programs\xod-client-electron\resources\arduino-libraries? That’s where I found the LCD headers & adding IRremote headers there allowed me to use them. I haven’t been able to get it to work with header files in the project.


No, unfortunately. Many things are tied to the process of transpiling the whole program to a single sketch file. Including arbitrary library code in it would be a nightmare to implement and maintain.

A better decision that pops up in my mind is a special pragma directive:

#pragma XOD require ""

struct State { ... };


void evaluate(Context ctx) {

Then when XOD sees the require pragma it will automatically download the code to a well-known location and any library user can straightly use the node.

The feature is yet to be implemented.


I would prefer an option that didn’t require internet access. Maybe allow URL or included with the project?

In Arduino IDE, using <header.h> implies to look in system files while “header.h” implies to look in code folder (or maybe that is reversed…). XOD seems to treat both the same.


The difference between #include <header.h> and #include "header.h" is up to compiler decision (GCC). It is a level lower than Arduino IDE or XOD. In practice, it only varies file lookup order.

I see. But when you install a library you access internet anyway. The C++ library may be installed at the same time.

Let’s imagine the C++ libraries are installed into XOD workspace, not into AppData\Local\Programs\.... In this case, if you’d like to replicate the same setup across many machines (e.g., in a school class), you’d have to install everything necessary once, and then simply copy the workspace directory to each PC even without network access.

Will it work for you?


That would be fine. I have to copy the AppData avrtools and XOD\__lib__ folders anyway to be able to use the software without internet access. I was just worried that the solution you were suggesting would require internet access any time it was encountered. Even your suggestion would work if it checked locally somewhere to see if it already existed before hitting the internet. I’m not sure how you would handle getting updates, though…

It would be nice if the include files could be included in the library. Maybe a __header__ folder whose contents gets copied to the system location (or XOD workspace) where it is needed when you Add Library? I would still have to manually copy it for use without internet access, but it provides a method to have everything needed by a library packaged in the library. The down-side of providing a URL to pull the headers is the URL could go away or its contents change. Maybe allow Add Library from local file option???


Yeah, the system would download libs once and not touch network if the Arduino library is here already.

Kill the xod/__ardulib__/IRremote and upload again to force the latest master to be installed. Alternatively, use

#pragma XOD require "" "v2.4.0"
// or
#pragma XOD require "" "96186317b251c04da595159402f80538c0be5eed"

To enforce a specific Git tag or commit.

Indeed, the repository may be deleted by its author, but doesn’t that mean he messed up the whole Arduino community? I mean that should be very rare. And even so, you can ensure the code will be “always” out there by forking the original repo with a single click to, say, "" and use this URL.

Yep, it’s tempting, but at the moment I see no quick-to-implement way to serialize all C++ library files properly into xodballs. I’m not sure it is a proper direction. Most major ecosystems do not carry dependencies with projects, they rely on libraries in the cloud hoping they are always there (JavaScript — NPM, Python — Pip, Ruby — Gems, Haskell — Cabal, etc).