PhotoKevin
PhotoKevin

Reputation: 97

Is it possible to develop an Arduino library outside of the documents folder?

I'm starting to develop an Arduino library and am following the instructions at Writing a Library for Arduino. Those instructions show putting the library code in a sketch for development

First, make a Morse directory inside of the libraries sub-directory of your sketchbook directory. Copy or move the Morse.h and Morse.cpp files into that directory. Now launch the Arduino environment. If you open the Sketch > Import Library menu, you should see Morse inside. The library will be compiled with sketches that use it. If the library doesn't seem to build, make sure that the files really end in .cpp and .h (with no extra .ino, .pde or .txt extension, for example).

My library does not show in Sketch->Import Library and I get a compile error in in .ino file. If I move the library over to documents\arduino\libraries it is found, but that's not a good place for initial dev work.

I've worked up a tiny, but complete, example:

D:\projects\Arduino\LibraryDev\LibraryDev.ino
D:\projects\Arduino\LibraryDev\libraries\CoolLibrary\library.properties
D:\projects\Arduino\LibraryDev\libraries\CoolLibrary\src\CoolLibrary.cpp
D:\projects\Arduino\LibraryDev\libraries\CoolLibrary\src\CoolLibrary.h
D:\projects\Arduino\LibraryDev\LibraryDev.ino:2:10: fatal error: CoolLibrary.h: No such file or directory

LibraryDev.ino

#include <Arduino.h>
#include "CoolLibrary.h"

void setup (void)
{

}

void loop (void)
{
   
}

library.properties (Mostly a direct copy from the example)

name=CoolLibrary
version=1.0.0
author=Cristian Maglie <[email protected]>, Pippo Pluto <[email protected]>
maintainer=Cristian Maglie <[email protected]>
sentence=A library that makes coding a Webserver a breeze.
paragraph=Supports HTTP1.1 and you can do GET and POST.
category=Communication
url=http://example.com/
architectures=*
depends=ArduinoHttpClient

CoolLibrary.cpp

#include "CoolLibrary.h"

void CoolLibaray::nothing (void)
{
}

CoolLibrary.h

class CoolLibaray
{
   void nothing (void);
};


Is the example just wrong, or is there some kind of extra configuration I need to do?

Comments telling me to move from Arduino IDE to a different development environment will be ignored.

OS: Window 10

Arduino IDE: 2.3.2

Upvotes: 0

Views: 44

Answers (1)

Guillius
Guillius

Reputation: 461

You could try to fix this include statement:

#include "CoolLibrary.h"

to

#include "/libraries/CoolLibrary/src/CoolLibrary.h"

Upvotes: 0

Related Questions