I'm trying to write a simple library to control the motors of my robotics team's Arduino Mega 2560 robot (I didn't build it! I just program it) with Arduino 1.0.2 on Windows 7.

Am using advice here for building and linking: http://provideyourown.com/2011/advanced-arduino-including-multiple-libraries/ -- Apparently this was partially incorrect according to WizenedEE, but I always try to ask questions the smart way and that meant searching before asking.

My library builds on the BMSerial library available from http://www.pololu.com/catalog/product/1495/resources

The remedy is simple - provide a directory specification to the file to include. In this example, to include the "Bounce.h" file, we specify the relative file path this way:

#include "../Bounce/Bounce.h"That is the relative path in Linux. In Windows, you may need to use backslashes ('\') instead. The '../' indicates the parent directory of the current one which is "MyLibrary". If we followed the path specifier, we go up one directory, which puts us in the library directory, and then down into the Bounce directory. Lastly, we then specify the filename to include.

Please don't do any of this. A simple "#include <Bounce.h>" or "#include "Bounce.h"" will work fine once you put the same include in the sketch, and it's possible ../Bounce/Bounce.h won't work since there's two possible places to put libraries. Also, forward slashes work in paths on windows as well, but don't on unix.

Once you've done that, please post compilable code (so the library plus a sketch) so we can get the same error and mess with it a little to try to debug it. Also post for what board you are compiling, because I think I've seen something like this error before and it depends on the board.

The remedy is simple - provide a directory specification to the file to include. In this example, to include the "Bounce.h" file, we specify the relative file path this way:

#include "../Bounce/Bounce.h"That is the relative path in Linux. In Windows, you may need to use backslashes ('\') instead. The '../' indicates the parent directory of the current one which is "MyLibrary". If we followed the path specifier, we go up one directory, which puts us in the library directory, and then down into the Bounce directory. Lastly, we then specify the filename to include.

Please don't do any of this. A simple "#include <Bounce.h>" or "#include "Bounce.h"" will work fine once you put the same include in the sketch, and it's possible ../Bounce/Bounce.h won't work since there's two possible places to put libraries. Also, forward slashes work in paths on windows as well, but don't on unix.

Once you've done that, please post compilable code (so the library plus a sketch) so we can get the same error and mess with it a little to try to debug it. Also post for what board you are compiling, because I think I've seen something like this error before and it depends on the board.

OK. Changed. I modified the original post to reflect your suggestions and added the do-nothing sketch. The error persists.

I believe this is a frequently asked question. Here's my understanding of the answer.

To use one library from another, it is necessary to include both libraries from the sketch, and make any references to the libraries from sketch-based code. (This can be awkward…) The Bitlash examples that include other libraries are structured this way: https://github.com/billroy/bitlash/tree/master/examples and yes it can lead to ugly things like passing around function pointers.

I've had no luck including one library directly in another. I hope someone will correct my understanding if it's wrong.

Well first of all, all I'm sayin' is I don't know how to do it directly, but have found a workaround, and I believe if you search the forum you will find other threads on the subject.

I think your characterization might be a little harsh. This is a feature of the Arduino build environment, not C++. Building sketches based on libraries is easy, in this system. Building libraries that cross-reference each other: I don't know how.

But don't give up. Your post says you've put the BMSerial library in the Arduino libraries/ folder in the usual place. Is there any reason you can't put it directly into your library folder and ship it with your library? I've found #includes work within the library's folder.

(I am still puzzling about why this would be causing a relocation error…)

As I understand how compilation and linking works, there should not be much of a significant difference between the two versions except for two additional ints. So something is really screwed up about the way Arduino builds.