How to compile library examples with arduino-cli

I've created a super-simple library, along with an example, which can be found here:

My question: while I'm writing the library I like to create examples to show how to use it. My question is how do I compile the examples using arduino-cli.

If I cd into the examples/Example1 directory and run

arduino-cli compile

I get the following error:

$ arduino-cli compile
/home/dhylands/software/MyLib/examples/Example1/Example1.ino:3:10: fatal error: MyLib.h: No such file or directory
    3 | #include "MyLib.h"
      |          ^~~~~~~~~
compilation terminated.

Used platform Version Path
rp2040:rp2040 3.7.0   /home/dhylands/.arduino15/internal/rp2040_rp2040_3.7.0_74b11d4c23dae2f7
Error during build: exit status 1

I'm using arduino-cli Version: 0.35.2 Commit: 01de174c Date: 2024-01-24T11:33:03Z running under ubuntu 22.04.

Answering my own question I figured out the following
1 - Using sketch.yml doesn't work with custom libraries. So I need to remove that file and pass in the --fqbn and other parameters on the command line.
2 - Checkout my git repository directly into my ~/Arduino/libraries folder. Then I can cd into the examples folder and with sketch.yml removed, things are working.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.