No such file or directory

I've created my own library from some code that works and I thought would be useful to re-use. I'm using an Apple Mac. I created a folder of the same name as the library in:

\Arduino\libraries\

we'll call it:

deque

which is where I have a couple of other libraries I imported. I created the deque.h file (it's a templated class so no .cpp file). I also created a keywords.txt file.

Re-started Auduino IDE, and the new library is listed. I can 'include the library' from the 'sketch' menu. But when I compile I get:

Arduino: 1.6.5 (Mac OS X), Board: "Arduino/Genuino Uno"

In file included from Controller.cpp:1:0:
Controller.h:1:19: fatal error: deque.h: No such file or directory
#include <deque.h>
^
compilation terminated.
Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

Any idea what I need to do to correct this error? But the file does exist!

The folder name should be deque NOT deque.h

Mark

As a general rule (i.e., not etched in stone), a library directory name shares the same name as the header (.h) and C++ (.cpp) files. Sometimes, when you extract a library from a downloaded ZIP file, it will expand to a directory with some name appended to it. For example, you might have a file:

MyLibrary_Master.ZIP

and upon unzipping, it becomes:

MyLibrary_Master/
MyLibrary.h
MyLibrary.cpp
etc...

In these cases, the directory path should be:

Arduino1.6.5/libraries/MyLibrary // Assumes your root directory is Arduino1.6.5

Note that the "_Master" is dropped.

I've just amended my original post as the folder name is:

deque

I don't know why the .h file can't be found!

Don't amend posts once someone has replied. You make those trying to help you look silly.

It is complaining because you're including Controller in your .ino file and not deque.h

The IDE can only find files that are included from the .ino file. If one of the headers includes something that isn't in the same folder with it, then the .ino has to have an include for it as well.

Are controller.h and deque.h in the same folder? If not, include deque.h in the .ino file and the problem will be solved.

Delta_G:
It is complaining because you're including Controller in your .ino file and not deque.h

The IDE can only find files that are included from the .ino file. If one of the headers includes something that isn't in the same folder with it, then the .ino has to have an include for it as well.

Are controller.h and deque.h in the same folder? If not, include deque.h in the .ino file and the problem will be solved.

The deque.h is in the \Arduino\libraries\deque\ folder. Then the Controller.h starts with:

#ifndef __CONTROLLER_H__
#define __CONTROLLER_H__

#include <deque.h>

The .ino file starts with:

#include <OnewireKeypad.h>
#include <LedControl.h>
#include "Controller.h"

... because the class in my Controller.h and Controller.cpp uses the deque class, as does the .ino file. If I put the deque.h in the same folder as the program and start my Controller.h with:

#ifndef __CONTROLLER_H__
#define __CONTROLLER_H__

#include "deque.h"

then everything compiles. If you are saying that libraries need to be included in the .ino file then that surely is a bug in the IDE?

I've added the deque.h file to the program files rather than in the libraries folder. Changed #include <deque.h> in the Controller.h to #include "deque.h", now it all compiles again. I can get on with my project. Just that I would like to know why this wasn't working. I even added the deque folder to a .zip file and imported the library that way, it created the deque folder in the libraries folder and on re-starting the Arduino IDE sure enough it was available, but on 'including library' into the Controller.h file it doesn't compile due to file not found!!

The deque.h is in the \Arduino\libraries\deque\ folder.

Why aren't you putting it it where it is intended to go, ie the libraries folder of the sketches folder ?

UKHeliBob:
Why aren't you putting it it where it is intended to go, ie the libraries folder of the sketches folder ?

When I use the following menu in the IDE:

Sketch | Include Library | Add .ZIP Library...

The imported library creates its own folder in:

\Users<User Name>\Documents\Arduino\libraries\

Which is where my deque folder is with the following within it:

deque.h
keywords.txt

The deque library is also included on the following menu:

Sketch | Include Library

When I use:

Sketch | Include Library | deque

The IDE adds the following to my Controller.h file:

#include <deque.h>

but then I get the error as in the first msg of this thread!

The imported library creates its own folder in:

\Users<User Name>\Documents\Arduino\libraries\

Which is where my deque folder is with the following within it:

deque.h
keywords.txt

Which is the right place.

However, in reply #6 you said

The deque.h is in the \Arduino\libraries\deque\ folder.

Hence my comment as it was not clear where exactly you had created the folder.

If you are saying that libraries need to be included in the .ino file then that surely is a bug in the IDE?

Or a feature, depending on your point of view. It is a fact, anyway (for most versions of the IDE).

PaulS:
Or a feature, depending on your point of view. It is a fact, anyway (for most versions of the IDE).

Thank you. At least I know what to do now should I want to use a 'library' in a file other than directly in the .ino file.

Any likelihood of this being fixed, and in the near future?

Any likelihood of this being fixed, and in the near future?

Nothing is broken. There is simply a matter that the feature doesn't do what you want. Being in the minority, do not hold out much hope for a change.