Arduino CLI not recognizing library even though it is installed

I am trying to use the Arduino CLI to compile a .ino file with a library in it (SR04). I have the library installed in both my Documents folder as well as in the Arduino15 folder. I installed the library with both the IDE and the arduino CLI. When I go to compile it, with arduino-cli compile --fqbn arduino:avr:uno Autonomous_car.ino, I get

Autonomous_car.ino:1:10: fatal error: SR04.h: No such file or directory
 #include <SR04.h>
compilation terminated.

Error during build: exit status 1

I am using the Arduino CLI downloaded through homebrew.

Where on your PC is the SR04.h file?

I have a Mac, Guess I should have specified that. It is in my /Users/MyName/Documents/Arduino/libraries. I also have one in the /Users/MyName/Library/Arduino15/staging/libraries folder

I would try copying the file to your ino directory/folder.

Bad idea. I predict linker errors.

1 Like

I deleted the files in my documents folder, and just used the files in the arduino15 folder. it worked perfectly.

Libraries should be installed under the libraries subfolder of the folder specified via Arduino CLI's directories.user configuration key. You can find the location of that user directory (the equivalent of the Arduino IDE's sketchbook folder) by running this command:

arduino-cli config dump

Information on Arduino CLI's configuration system here:

/Users/MyName/Library/Arduino15/staging is directories.downloads.

This is the location the archives of libraries and boards platforms (AKA "cores") are staged at during the Library Manager (e.g., arduino-cli lib install) or Boards Manager (e.g., arduino-cli core install) updates.

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