#include file locations

An #include statement written as “fileneme.h” will find filename.h in the current sketch directory.

On the other hand, a #include <filename.h> will find the file where?

What directories does arduino use for header files that are not inside the sketch folder and how can a new header file be added to a sketch without the .h file being in the sketch folder?

Here is what I tried to do:

#include <myheader.h>

Then, in c:\users\mike\documents\arduino\libraries\ the file myheader.h was inserted. Didn’t work

Then, in c:\users\mike\documents\arduino\libraries\myheader\ the file myheader.h was inserted. Didn’t work

Then in the c:\users\mike\documents\arduino\libraries\myheader\SRC\ was added and the file myheader.h was inserted there. Didn’t work ether.

Where does arduino search for these and how can you add one?

#include <filename.h>” and “#include “filename.h”” do the same thing.

#include <filename.h>” and “#include “filename.h”” do the same thing.

They don’t (or are not supposed to).

#include “filename.h” will look in the sketch folder first and next in the library directories
#include <filename.h> will only look in the library directories

The use of angle brackets (<>) causes the compiler to look for the file on the default path for the library directory. Depending upon installation, this path is the Documents/Arduino/libraries directory on a Windows machine.

The use of double quotes ("") around the header file causes the compiler to look in the sketch working directory for the header file. The default sketch directory can be seen in the File → Preferences menu option. If the file is not found there, it will also search the default library directory.

"this path is the Documents/Arduino/libraries directory on a Windows machine. "

Yes, but in my original post, that is where I put the myheader.h file and #include <myheader.h> did not find it. There must be more to it than simply putting the header in that directory.

That path can be different if you installed things differently. What happens if you put it in the current working directory and use double quotes?

Did you restart the IDE after creating your directories?

If you want the header file to be found when you place it in the libraries directory you need to place it in a folder of the same name without the '.h'.

c:\users\mike\documents\arduino\libraries\myheader\myheader.h

And then restart the IDE.

Thanks for the advice. I was having similar problems being able to include certain .h files.

putting it in the Libraries directory in a folder with same name without the .h worked.

hoke

Thanks for the advice. I was having similar problems being able to include certain .h files.

putting it in the Libraries directory in a folder with same name without the .h worked.

hoke

tf68: If you want the header file to be found when you place it in the libraries directory you need to place it in a folder of the same name without the '.h'.

c:\users\mike\documents\arduino\libraries\myheader\myheader.h

This is incorrect. While it is common practice to do this, it is not required. The IDE searches many places and directories within those places looking for headers. bundled libraries, core area, sketchbook libraries, to list a few. Once it finds the header file, it then creates a -I option to the compiler to add the directory where the header file is found to the compiler search path. The issue that can arise is when there are collisions. (multiple directories with the same header file name) Using a directory of the same name as the header will give the directory priority when the header file is found in multiple places.

--- bill

Hi I have the same problem.

always certain libraries missing.

even if they are in the "search" folders.

what to do?

Mainly ESP functions

now latest is missing functional c code, which is present in :

/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/xtensa-lx106-elf/include/c++/4.8.2

why is it not found?

In the Arduino IDE Open File|Preferences At the bottom it defines where the prferences file lives (click it) C:\Users\XXX\AppData\Local\Arduino15\preferences.txt

Now Navigate to:

.\packages\package_name\hardware\samd\X.X.X\Libraries\Library_name\

here are the *.cpp, *.h files

PS: Hm,mmm. It took reading more than 10 forum threads and finally fumbling myself found the corrcet info!

ianfinlay_aus: In the Arduino IDE Open File|Preferences At the bottom it defines where the prferences file lives (click it) C:\Users\XXX\AppData\Local\Arduino15\preferences.txt

Now Navigate to:

.\packages\package_name\hardware\samd\X.X.X\Libraries\Library_name\

here are the *.cpp, *.h files

I do not have any entry in my preferences.txt file pertaining to hardware or packages. I am running into the same problem in that my version 1.8.9 IDE on a Windows 7 box does not find any of the header files specific to the INO I am trying to compile.

How do I tell the IDE where to look for those files in the project directory under Libraries?

Thank you.

Installed on Windows 10, I found the libraries in the following directory. You need admin rights to view it.

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.33.0_x86__mdqgnx93n4wtt\libraries

I suspect it might differ on other machines but would still be of the form

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE*\libraries

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.33.0_x86__mdqgnx93n4wtt\libraries[/quot That looks completely wrong.

Which version of the IDE do you have, where did you get it from and how did you install it ?

UKHeliBob:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.33.0_x86__mdqgnx93n4wtt\libraries

That looks completely wrong.

Which version of the IDE do you have, where did you get it from and how did you install it ?

That's the Windows Store version.

No wonder it looks wrong

What reason is there for using the Windows Store version and which release of the IDE is it ?