Search path for additional libraries?

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.

There are quite a few files, namely:

algorithm
avr_config.h
basic_definitions
bitset
cctype
char_traits.h
concept_checks.h
container_concepts.h
cstddef
deque
functional
hash_map
hash_set
iomanip
ios
iosfwd
iostream
istream
istream_helpers
iterator
lcdostream
limits
list
locale
map
memory
new
new.cpp
numeric
ostream
ostream_helpers
queue
sequence_concepts.h
serstream
set
slist
sstream
stack
stl_algo.h
stl_algobase.h
stl_alloc.h
stl_bvector.h
stl_config.h
stl_construct.h
stl_ctraits_fns.h
stl_deque.h
stl_function.h
stl_hash_fun.h
stl_hash_map.h
stl_hash_set.h
stl_hashtable.h
stl_heap.h
stl_iterator.h
stl_iterator_base.h
stl_list.h
stl_map.h
stl_multimap.h
stl_multiset.h
stl_numeric.h
stl_pair.h
stl_queue.h
stl_range_errors.h
stl_raw_storage_iter.h
stl_relops.h
stl_set.h
stl_slist.h
stl_stack.h
stl_string_fwd.h
stl_tempbuf.h
stl_tree.h
stl_uninitialized.h
stl_vector.h
streambuf
string
type_traits.h
utility
valarray
vector

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!

Try this...

• Create a new library directory (e.g. "{SketchRoot}\libraries\stl")

• Copy all the STL files into the new library directory

• Create a single dot-cpp file in the new library directory that includes all the STL files

• Create a test Sketch that includes a few of the STL headers

Does that work?

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...

vector.h ...

#include <vector>

Sketch...

#include <vector.h>

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 don't mean to necropost, but...

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

vector.png

error.png

Where did you put vector.h?

Which version of the IDE are you using?

(Boy, am I a late responder or what?)

I was using (and am still using) version 1.6.7.

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? >___<

In your sketchbook / library directory?