Go Down

Topic: #include documentation (Read 1 time) previous topic - next topic

captnKrunch

why doesn't the documentation for #include reveal where the file is included from?  or is this where the "intuitive" part comes in?

AlphaBeta

What do you mean?

#include "drive:/this/is/where/my/file/is/from.h"


#include <a_file_in_system_path.h>

PaulS

The #include statement just says to include a file.

There are additional arguments to the compiler that define where include files are to be looked for.

There are differences in the syntax of the include command that also influence where the file is included from.

Code: [Select]
#include <fileName.h>
#include "fileName.h"


The <> symbols tell the compiler to look in the local search path and the global search path. The "" symbols tell the compiler to look in the local search path only.

The local and global search paths are also influenced by environment variable settings.

So, answering the question of where is this file include from is a complex question.

captnKrunch

Alphabeta:  yes I can read.  You might want to reflect on why both of your examples work and why you think the documentation indicates both examples should work.

PaulS: your answer is very close to the spirit of my question and very illuminating.  However, you stopped short of telling me how to set the paths which apparently is the real answer to my implied question.

PaulS

#4
Jun 07, 2010, 11:24 am Last Edit: Jun 07, 2010, 11:28 am by PaulS Reason: 1
Yes, I did stop short of telling you how to change the paths. Changing the paths is something that is to be done only with extreme care. The environment variables that a given compiler uses are compiler-dependent. The default paths are OD dependent.

In general, though, if you have to ask the question, you shouldn't be fiddling with things.

Where the Arduino IDE looks for libraries is version-dependent, too. For some details:
http://arduino.cc/en/Reference/Libraries

You didn't say if you are having problems with a specific library, determining where to put it, or were just asking a general question.

If the original post was for general information, you now have that. If it concerned a specific library being accessed by a specific version of the IDE on a specific OS, tell us what library, what version, and what OS.

Oh, and AlphaBeta gave the details for how to absolutely ensure that a specific header file gets loaded from wherever, with any version of the IDE, on any OS that uses forward slashes. You can, of course, reverse them if you are on a backwards OS.

That does NOT, howere, ensure that the compiler will be able to locate the corresponding source code to compile, or the corresponding object files to link, so, use that method with care.

captnKrunch

PaulS:  Thanks again.  My original post was for two specific reasons (1) I don't understand why the arduino documentation is so grossly incomplete after so long and (2) I've been trying to put the FAT16 library somewhere where version 18 can find it.  I'm too old to be pursuing general information about somebody's arbitrary choices.  

The "libraries" documentation I can find (for v 18) says to put a "libraries" folder in the sketchbook folder (itself astonishingly omitted from the standard v18 download) which I think I have done without any improvement.

OK, I agree that my 50 years as a programmer does not qualify me to actually dare to change the path but would it be asking too much for someone to reveal what the "global" and "local" paths are set to in v18 by default?  Might someone want to reflect that information into the documentation for posterity?

PaulS

I'm going to go out on a limb here and suggest that the reason that the documentation is not up to your standards is that it is written by people who are more interested in getting the library out there for people to use than they are in documenting every last little detail.

It's easy in the rush to get something out to overlook a few details.

For instance, since the Arduino looks in different places depending on the operating system, people that do not have every OS available may not know precisely where to put the libraries on operating systems other than the one that they developed the library on.

I might point in, politely of course, that I mentioned OS as a concern (although I did manage to mis-spell a two letter acronym) and you haven't documented which OS you are using.

If you were to do that, someone here could tell you EXACTLY where the library needs to be in order for the Arduino compiler to find it.

I'd tell you exactly what the environment variables were that the compiler looked at, if I knew. It wouldn't be that difficult to find out, if I was interested.

But, I know where to put libraries on Windows XP so that the Arduino compiler can find them, and I'm too lazy to look up what they are for your OS.

Oh, wait, I can't. I don't know what OS you are using.

captnKrunch

PaulS:  It seems strange that the location of libraries is a detail and has nothing at all to do with the libraries themselves but a choice by the compiler writer but then I'm a arduino newbie.  In any case, I am reluctantly using windows 7.  I managed to find a usable solution for XP and v15 but, of course, that knowledge is no longer useful.  I infer from your last response that there is another place (path?) for the linker?  If that is correct, could I be trusted with that information too?  if you aren't a windows 7 user, i would be happy with a method to locate this information myself and I'll stop bugging you.

retrolefty

#8
Jun 08, 2010, 07:05 am Last Edit: Jun 08, 2010, 07:16 am by retrolefty Reason: 1
captn'

Below are the two locations on my system (XP SP3) that library folders are located, or where 'new' libraries folders can be placed.

Keep in mind that prior to version 18 (or was it 17?) libraries were only located in the first path. The problem with that was each time a new Arduino IDE came out the user had the burden to remember and copy and move any non-core Arduino library folders into the new versions installed location. This ability to store 'user' libraries into the users sketch folder locations which remains fixed even when upgrading the IDE was a very nice feature to add, but does add another detail for new users to learn. Keep in mind any users libraries instructions prior to version 18 didn't know about this future added location feature so their published instructions are not presently optimized for this new dual library location feature.

Primary 'core' library folders location:
C:\Documents and Settings\Primary Windows User\My Documents\My Programs\Arduino\arduino-0018\libraries

10 Folders:

EEPROM
Ethernet
Firmata
LiquidCrystal
Matrix
Servo
SoftwareSerial
Sprite
Stepper
Wire


0 Files:

Secondary library folders for user and 3rd party library folders:
C:\Documents and Settings\Primary Windows User\My Documents\Arduino\libraries

8 Folders:

Button
DS1307
Flash
MsTimer2
Streaming
String
Tone
__MACOSX


0 Files:

Not sure that will help with a system 7, and parts of the path are user determined during original set-up and installation, but it should show the logic.

Also if you open the Arduino IDE and click on the sketch button and slide down to Import Library, you will then see two lists of libraries, the top one are the 'core' Arduino libraries, and the second list are the libraries located in the users sketch/libraries folder.

Lefty

mellis

#9
Jun 13, 2010, 10:39 pm Last Edit: Jun 13, 2010, 10:41 pm by mellis Reason: 1
Also, see: http://arduino.cc/en/Guide/Environment#libraries for information on installing library and http://code.google.com/p/arduino/wiki/BuildProcess for more details about the build process (including paths) used by the IDE.

fragtastic69

#10
Jun 15, 2010, 06:52 pm Last Edit: Jun 15, 2010, 06:56 pm by fragtastic69 Reason: 1
@ captnKrunch / admin
I think this should really be added to the #include documentation.
There was another post about this i just saw asking the same thing.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1276204960

captnKrunch

Thanks guys.  All of this was very helpful.  I'm up and running.  I still think some of this info should be reflected into the documentation though.

As a side note, I heartily recommend the FAT16 software package as a great job of coding and user level documentation if you need to implement a PC compatible data logger using SD cards.

fdufnews

Quote
I still think some of this info should be reflected into the documentation though.

Well it is. The information is in the readme.txt file you find in the directory you install arduino software.
* Support for third-party libraries in the SKETCHBOOK/libraries folder.


and here http://arduino.cc/en/Guide/Environment you find this
There is a list of libraries in the reference. Some libraries are included with the Arduino software. Others can be downloaded from a variety of sources. To install these third-party libraries, create a directory called libraries within your sketchbook directory. Then unzip the library there. For example, to install the DateTime library, its files should be in the /libraries/DateTime sub-folder of your sketchbook folder.

Go Up