Conflicting Libraries

Hi all,

I have found similar questions to this, and I understand (sort of) what the solution is, but was hoping someone might know a bit more about Arduino libraries to help me out.

I am trying to use both the Servo and Tone libraries in a project. They are conflicting, in particular through the use of vector 11. I think that I have to either change, or rename, this 'vector' but don't know how to identify a vector within the library '.h' files.

Any help to point me in the right direction would be greatly appreciated.

Thanks!

I just searched for vector in the libraries and it is not there. Do you mind posting the error you are getting? Maybe it will help clarify things.

Thanks for the reply,

I'm at work so I don't have the exact error, but it is almost identical to the following:

core.a(Tone.cpp.o): In function `__vector_7':

C:\Program Files (x86)\arduino-1.0.1\hardware\arduino\cores\arduino/Tone.cpp:523: multiple definition of `__vector_7'

NewPing\NewPing.cpp.o:C:\Program Files (x86)\arduino-1.0.1\libraries\NewPing/NewPing.cpp:214: first defined here

I also tried searching the libraries for "vector" with no success, my guess is that it is referring to a variable being used within the library (?).

Thanks again.

I grepped (searched) every single file in the Arduino 1.0.1 software download and the only results were .o files that contained __vector_7.

Then I checked out line 523 in Tone.cpp and found the definition for an ISR called ISR(TIMER2_COMPA_vect).

grepping Tone.cpp again I found #define TIMER2_COMPA_vect TIMER2_COMP_vect

grepping all files for TIMER2_COMP_vect resulted in 23 files with names like iom???.h that contained #define TIMER2_COMP_vect    _VECTOR(#)
where # = 3, 4, 9, and 10. But there were no 7's.

Switching tactics I googled Tone.cpp:523: multiple definition of `__vector_7'

This post in the forums might contain your solution if you are not using interrupts with the Ping sensor. NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.7 - #253 by teckel - Sensors - Arduino Forum

it's happen the same things to me ...

there was two libraries in conflict because was used the same pin ...

maybe you can try to change the pin ...

gnux

Thanks again,

I should have been more clear. The error I posted there was almost what I was experiencing. The following is the actual error (the only difference is the vector and libraries involved):

/tmp/build5446.tmp/Tone/Tone.cpp.o: In function `__vector_11':

/Users/oli/Documents/Arduino/libraries/Tone/Tone.cpp:438: multiple definition of `__vector_11'

/tmp/build5446.tmp/Servo/Servo.cpp.o:/Applications/Arduino.app/Contents/Resources/Java/libraries/Servo/Servo.cpp:103: first defined here

I have googled some more and found that the Tone and Servo libraries are using the same timer on the Uno, I think these are necessary for both modules, and don't know if I can change them.

Any thoughts?

Yes, they use the same Timer.

You might want to look at the new ToneAC library here on the forum - http://arduino.cc/forum/index.php/topic,142097.0.html

It seems to use Timer 1, rather than Timer 2, this avoiding the conflict with the. Servo library that the original Tone library has.

Hainsy:
Thanks again,

I should have been more clear. The error I posted there was almost what I was experiencing. The following is the actual error (the only difference is the vector and libraries involved):

/tmp/build5446.tmp/Tone/Tone.cpp.o: In function `__vector_11':

/Users/oli/Documents/Arduino/libraries/Tone/Tone.cpp:438: multiple definition of `__vector_11'

/tmp/build5446.tmp/Servo/Servo.cpp.o:/Applications/Arduino.app/Contents/Resources/Java/libraries/Servo/Servo.cpp:103: first defined here




I have googled some more and found that the Tone and Servo libraries are using the same timer on the Uno, I think these are necessary for both modules, and don't know if I can change them.

Any thoughts?

See the following post:

http://forum.arduino.cc/index.php?topic=106043.msg1312639.html#msg1312639

Tim

I've had a problem with using "tone" function and NewPing (I'm using for sonar).
This was due to the issue with timers.
Just replaced the first with "NewTone" library which resolved this conflict, but now this NewTone.h
is in conflict with Servo.h

error message:
In function NewTone(unsigned char, unsigned long, unsigned long)': (.text+0x0): multiple definition of __vector_17'
libraries\Servo\avr\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here
Error compiling for board Arduino/Genuino Mega or Mega 2560.

I have a similar error. For me, the two libraries are Servo and IRremote.

Capture2.PNG