Pages: [1]   Go Down
Author Topic: Include file location  (Read 826 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using IDE v1.0 on Windows 7 and I'm trying to include a header file that is not specific to a library.  I use this for configuration data (IP Address, Modbus ID, analog mapping values, etc.).  When ever I try to compile the sketch, I get an error about not finding the .h file.  Where exactly should these (non-library specific) files go?

Thanks in advance!

Len
Logged

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 89
Walking on Nails
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Put it in your sketch directory. If you need it in more than a single sketch you have to make it a library.
Logged

loved the 68000 assembler back then and now I have to deal with THIS 8 bit thingy

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What does it mean to "make it a library" exactly?  I have about 10 different header (.h) files and I change my sketch to include the particular one I'm compiling but there is no "code" in any of them (mostly #defines) so I don't know what I'd have to put in the .cpp file to make it a library.

Is there no way I can specify where to look for files like this?  If I put all of them in my sketch folder, can I just include the one I want or will it include ALL of the files in the sketch folder?

len
Logged

California
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

"Making it a library" simply means putting it in its own directory the libraries directory. You don't need to use a .cpp file; that's a convention, not a requirement.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does this mean that I'll need a folder for each of my include files?
Logged

California
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Only if you want to use the Sketch >> Import Library... properly. If you don't use it, it's not necessary.
Logged

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 89
Walking on Nails
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could store all you settings in one 'library' and then include only what you need. You have to make it a library because of the way Arduino handles paths - that's why you have to include all used libraries in the sketch even when you don't use them directly in the sketch but in another file included in the sketch.

You could make a library called MyLibrary located in a subdirectory named MyLibrary (in the user libraries path) containing all your header files. Importing this library includes all header files in the sketch making them usable in other files, too. Just remove the not needed from the sketch.
Logged

loved the 68000 assembler back then and now I have to deal with THIS 8 bit thingy

Pages: [1]   Go Up
Jump to: