[RESOLVED] Linking a library while writing an other

Hello,
I’m trying to write a library to control my robot. I need to use the library “Wire”, but when I include the file ( #include <Wire.h> ) it does like in it was not included: " ‘Wire’ was not declared in this scope. “, or sometimes " TwoWire’ does not name a type”.

I don’t know what I should do to make it work. Is there a solution except copying the library into my code?
thank you~

Have you put #include <Wire.h> in both your .cpp and .h files? Also it might be a good idea to include it in the actual sketch that will use your library.
And perhaps post the errors so we can have a look.
Thanks

My code is quite big so I will just show you the idea:

MyFile.h:

#include <Wire.h>

MyFile.cpp

#include "MyFile.h"
#include <Wire.h>

void myFunction(){
    Wire.begin();
}

the error is :
error: ‘Wire’ was not declared in this scope

Well if that's just the "idea" how can we know what is actually happening? Because that specific example (correct me if I'm wrong) wouldn't work at all. See here:

It is a lot different from defining a function in-sketch.

I just tried to include Wire into the code using my library and it works. I don't really like this solution because both I don't understand why it work, and I have to explain it to the future users of my library :~
But thank you very much, if I have no other solutions I can apply this one and take the time to find out another one!

indeed:
Well if that's just the "idea" how can we know what is actually happening? Because that specific example (correct me if I'm wrong) wouldn't work at all. See here:
http://arduino.cc/en/Hacking/LibraryTutorial
It is a lot different from defining a function in-sketch.

Yes sorry I forgot to add the declaration of my function into the .h file, but I did it in my code. Moreover the function is a method for a class.

Glad I could help. As for why it works, it is because the actual library that is executing the code so it needs to have its libraries included so it can execute it. A bit annoying but that’s just how it is.

Understood, I didn’t expected that but I will do with it. :wink:
Thank you again!