Creating a library that uses Wire

Hi all,

I'm trying to write (and compile :)) a library from within the Arduino 0011 Windows application.

I'm following this tutorial: http://www.arduino.cc/en/Hacking/LibraryTutorial.

I have been able to write a simple library without any problems, and from a new sketch I have been able to create a new instance of my class, call its methods and so on.

I want the library to coordinate actions on the I2C bus, so I want to include the Wire library, letting the Wire library handle I2C while my library coordinates several devices on the bus.

However, whatever I do, I can't seem to get the code to compile properly, the .o file is created, but I get errors like this when I compile:

hardware\libraries\Toot/Toot.h:5:21: error: TwoWire.h: No such file or directory

I have tried to #include to "Wire.h", "TwoWire.h", <Wire.h> and <TwoWire.h> but nothing seems to work.

I'm not sure where the "base path" for the referencing is, so I'm not sure how to specify a relative path, and I have no idea what the syntax is for speciftying an absolute path.

Am I missing something obvious?

#ifndef Toot_h
#define Toot_h

#include "WConstants.h"
#include "Wire.h"

...etc...

Any advice would be greatly appreciated, before I am driven mad! :o Too late. :slight_smile:

Problem solved:

#include "../../../../libraries/Wire/Wire.h"

I really didn't want to hard code the directory separators (I come from a Java programming background, where this is an absolute no-no).

But since this code is currently going to be on my windows machine only, this will do for now. :slight_smile:

You need to #include <Wire.h> in your main sketch as well as your library. Right now, the code which detects library dependencies (to determine include paths) only looks at the sketch, not the other libraries.