Location of library files

Sorry for the dumb question, but where exactly should the library files go? 

At the same location as my sketch (which was copied directly from the website), I have a directory "libraries" which contains the unzipped contents of EmonLib, including EmonLib.h.  The compiler, however, is not seeing this file because it's complaining about the unknown class, EnergyMonitor.

The solution is no doubt very simple, but so exasperating when you're not in the know!

TIA, Robin

TrystanLea's picture

Re: Location of library files

Have you tried restarting the arduino IDE?

calypso_rae's picture

Re: Location of library files

Yes, I checked that before posting this SOS.  Switching the Mac on from cold makes no difference.

At the top of the sketch is the line:

#include "EmonLib.h"              // Include Emon Library

Where does the compiler expect to find that file? Does it always look in a co-located folder called "libraries"?  Should all library files be put in this in this single folder, or should they be sub-grouped by their individual library names.  At present I have:

/Documents/Arduino/RAE_1.ino

/Documents/Arduino/libraries/EmonLib.h

/Documents/Arduino/libraries/EmonLib.cpp

/Documents/Arduino/libraries/ReadMe.txt

/Documents/Arduino/libraries/Examples ...

Sorry if I'm the only person to be having trouble with this ...

I'm not yet familiar with the emon file structure.  I've simply copied the sketch which measures voltage and power and am hoping that it will compile, as the "blink" demo does.  My ac-controller has just arrived so I'm keen to start diverting current!

 

 

 

Lloyd's picture

Re: Location of library files

I'm not familar with arduino on a MAC, but I'm sure that what you have is probably wrong.

On a PC, there will be an arduino folder (c:\arduino), which contains the release.  Within this are a number of distribution folders (drivers, hardware, java...) and library. Within this there is a folder for each library.  So c:\arduino\library\emonlib will contain emonlib.h,emonlib.cpp, readme.txt and examples.  You should be able to find all the libraries that came with the arduino distribution, and add any additional libraries as folders.

Your sketch should be located outside of this structure, to keep it separate from the distribution, probably in /documents/arduino as you have it, although I would probably create a folder for each project you are working on.

Hope this helps, 

Lloyd

 

 

calypso_rae's picture

Re: Location of library files

Thanks Lloyd, it compiles nicely now :)

Robin

calypso_rae's picture

Re: Location of library files

Thinking about file structures while changing the van's oil in the rain (as you do), the penny finally dropped, as it were.  Previously, I had created a "libraries" folder in my own working area and then put the EmonLib files there.  I should instead have located and used the existing libraries folder in the Arduino IDE location.  My file setup, including EmonLib, is now hopefully as it should be.

A few observations may be of interest to the team:

In the "Building Blocks" page, "Arduino sketch - current only", it says: Download EmonLib from github and place in your arduino libraries folder.  I had no idea about 'github', but thankfully there is a link to EmonLib on the next line so I clicked it.  This resulted in a .zip file appearing on my desktop.  When inflated, this created a small collection of items in a similarly named folder.  Unfortunately, its name was not EmonLib; it was more complex than that.  The environment won't work with that longer name, it has to be "EmonLib".

Yesterday, I didn't know what was in the EmonLib "Examples" folder but have since realised that it contains the same two sketches that appear online in the "Building Blocks" pages.  If I'd known that beforehand, I wouldn't have needed to copy these online sketches to TextEdit on the Mac, then port them to the laptop via a memory stick, paste them into blank Arduino sketch pages, replace the c/r characters that had been lost in transit, and finally save them into my working area.  The two sketches that I needed were right there all the time, safely preserved in the library.  Is there any way that I could have known this from the online documentation?

I think that a diagram or two showing how the working environment should be configured would be ever so helpful to newcomers.

Great site.  Hope this feedback is of some use.

 

TrystanLea's picture

Re: Location of library files

Thankyou for the suggestions, I will update the libraries installation notes soon

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.