After trying to get STL to work (successfully) I have a question about the best way of installing it.
The instructions from this web site:
Say:
If you want to use the STL from within the popular Arduino IDE then all you need to do is copy all the files in the avr-stl\include directory into the hardware\tools\avr\avr\include subdirectory of the Arduino installation. For example, on my system I would copy all the header files into here: C:\Program Files (x86)\arduino-0021\hardware\tools\avr\avr\include.
Now I've done that, and it works, but I am a bit uneasy. As people have advised in the past, it is best not to change the installation directory, in case version 0023 ever is released, and it is overwritten.
Not all of them end in .h (which is the standard for the standard libraries apparently).
It won't work to put them into a "normal" library because the IDE won't copy all those files into the temporary directory it uses to do a build, especially as you may explicitly refer to only a couple, and because a lot of them refer to each other.
But is there another way? When I was playing with the Sanguino I was advised to copy its special header files into:
<my working path>/Arduino/hardware/sanguino
So is there another "local" directory (eg. /Arduino/hardware/uno ?) that these files can be copied to, and still get used automatically during compilations?
If you copy them into .../arduino-0022/... the risk is only that when 0023 is released you will have to copy them in AGAIN. Seems like only a minor annoyance.
In any case, that's pretty cool STL running on Arduino. I'm going to have to try this out!
No, and I tried a few permutations. One problem is that the .h files are not supposed to be directly include because you do this:
#include <vector>
It doesn't pick up that it needs to look in the stl directory if I do that.
But if I do:
#include <stl_vector.h>
... I get an error because stl_vector.h is designed to be included from .
If I include this:
#include <stl.cpp>
... where stl.cpp is the "hold all" file that includes all the other files I get this:
vector_test.cpp:1:19: error: stl.cpp: No such file or directory
So it must look for .h files to mark a library, not .cpp ones.
If I include this:
#include <stl.h>
... where stl.cpp is the "hold all" file that includes all the other files I get a lot of errors, eg.
In file included from /Users/nick/Documents/Arduino/libraries/stl/stl.h:21,
from vector_test.cpp:1:
/Users/nick/Documents/Arduino/libraries/stl/lcdostream:21:27: error: LiquidCrystal.h: No such file or directory
In file included from /Users/nick/Documents/Arduino/libraries/stl/stl.h:77,
from vector_test.cpp:1:
/Users/nick/Documents/Arduino/libraries/stl/valarray:18:17: error: new.h: No such file or directory
In file included from /Users/nick/Documents/Arduino/libraries/stl/stl_algobase.h:64,
from /Users/nick/Documents/Arduino/libraries/stl/algorithm:30,
from /Users/nick/Documents/Arduino/libraries/stl/stl.h:1,
from vector_test.cpp:1:
/Users/nick/Documents/Arduino/libraries/stl/stl_iterator.h:589: error: expected type-specifier before 'char_traits'
If I do this:
#include <dummy.h>
... where "dummy.h" is a file with a comment in it, but no includes, then I get this:
cc1plus: error: /Users/nick/Documents/Arduino/libraries/stl/utility: not a directory
So in that case it looks like it has thought that the files without the .h are a subdirectory and tried to copy or otherwise access them, but it turns out they are files not directories. Maybe this is a bug in the IDE, just assuming that a file without a suffix is a directory.
So it must look for .h files to mark a library, not .cpp ones.
I bet you're right.
Maybe this is a bug in the IDE, just assuming that a file without a suffix is a directory.
Definitely looks like it.
It's kind of nauseating but you could try a dot-h file for each no-extension file ("vector.h" for "vector") that just includes the no-extension file...
Thanks for the suggestion, but I'll leave it for now. I was hoping I could get an install by simply copying to somewhere other than the installation directory, because that would be more permanent. I was hoping other people would get interested in the STL, and having to make dozens of files to get it installed would put them off.
I tried this, and it didn't work. It's really irritating because I've now ended up installing the whole STL to use one library (vector), only to find I can't use it >:I
But, now that I look at it, I seem to have installed the library in my sketchbook, as opposed to the actual libraries folder.
...could that be the issue? >___<