Problem with 2 libraries

Hello Ardunio's

Writeing a prog useing IRremote.h and DmxSimple.h and i get a compile clash like:

DmxSimple.cpp.o: In function 'Vector_9' DmxSimple.ccp:141: multiple definition of 'vector_9' IRremote.cpp:264: first defined here

I recon one of the two have to change. But i am a newbe to libraries. Every thing was going fine up to then.

Bye from France

I recon one of the two have to change. But i am a newbe to libraries.

Sounds like you know what to do...

Just go into one of the two libraries, and change all instances (in all header files and all source code files, and anywhere else that looks suspicious) of "__vector_9" to something else.

One thing: I would suggest prepending something that goes with the library name on whichever one you change; for instance if you change the DmxSimple library, prepend "dmx" to the variable - thus "__dmx_vector_9".

Note that any changes you make, you might have to keep in mind for when referencing any documentation (if any of them are public variables or such, that can be altered by your own code outside of the library - however, these seem to be likely private members, because of the prepended underscores; at least, they should be).

You might also pass along the suggestion to the authors of -both- libraries so they can update them, and prevent these namespace clashes (this should really be something all authors of libraries should do).

Once you've made the changes, you should be able to compile your code successfully (unless other clashes occur, of course). Good luck.


Thanks for speedy reply. I looked in the libraries of IRremote.cpp and found this:

ISR(TIMER2_OVF_vect) {

not exsacly right but i did change it to

ISR(TIMER2_OVF_irvect) {

and it compiled ok but the program is very upset. Which i recon is normal as i changed only one varable but where is the other?

i looked IRremote.h and IRremoteInt.h and DmxSimple.cpp and DmxSimple.h but no __vector_9 or vect.

i will stop for tonight and go and by bottle of wine which will clear my old brain for tomorrow.

thanks for the reply

Sorry for what I am going to say, but without further work, I think you will not be able to use both libraries at the same time. It you are sooooooo lucky, maybe you can. But at first look, no.

What is happening here is that both libraries use Timer/Counter 2 to throw an interrupt: Timer/Counter 2 Overflow.

The name of the interrupts are in \hardware\tools\avr\avr\include\avr\iomx8.h In that file you will find:

#define TIMER2_OVF_vect                  _VECTOR(9)

What is incredible is that it works with and undefined define TIMER2_OVF_irvect.

So, what you did is "disconnect" the IR interrupt service.

Posible solutions? 1.- If both modules use the same frequency (barely possible), just converting one of the service in one module to a function, and calling that function from the other module's interrupt service will be enought.

2.- Reprogram one of the modules to use Timer/Counter 1 or Timer/Counter 0.

3.- Do the 1 solution, using the highest frequency and control by software the freq of the slower module (just a counter to know when to call the function, for example).

I have been watching both sourcecodes. If you want all to use Timer2 (as have been thought), you will have to make several changes... many :( I have found another "easy" way :) The possible solution is hang the Dmx interrupt service to the Timer0 overflow. Timer 0 is used by arduino to count time, usefull to delay(). But, if Dmx service doesn't take too much time, it should work :)

Steps: 1.- Modify DmxSimple.cpp to not use any timer/counter 2.- Change ISR(...) for a simple function void dmx..() { ...} 3.- Go to \hardware\arduino\cores\arduino\wiring.c and add at the end of the ISR the call to theDmxSimple function of 2) 4.- When programming, set DmxPin to a pin different of D3 (call usePin() before dmxBegin() ), because D3 is used by IR library.

OR you can talk to Peter Knight;username=Cathedrow, author of DmxSimple. :)

Thanks to all. I have written loads of code over the years but not very much on changing libraries or touching interrupts. In Peter Knights code he says don't touch and i lisen to guys who right better code than me so i will contact Peter Knight.

It's so amazing what you can connect to an Arduino and that someone out there has already written code to use it.

Thanks again.