[SOLVED] Strange compilation error

Hi everybody!

I'm making a little robot using Arduino and it works fine (you can see how it works on the embedded video).

The robot walk alone perfectly but today I tried to use an infrared remote with an infrared receptor to use my robot like an RC car, and I had this error at compilation (I'm using IRremote library):

 

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

D:\Program Files\Arduino\hardware\arduino\cores\arduino/Tone.cpp:535: multiple definition of `__vector_7'

IRremote\IRremote.cpp.o:D:\Program Files\Arduino\libraries\IRremote/IRremote.cpp:311: first defined here

 

So I searched that error on the internet and I found something wich looks like a solution. I changed the code of "IRremoteInt.h" putting this

 

  #define IR_USE_TIMER1   // tx = pin 9

  //#define IR_USE_TIMER2     // tx = pin 3

 

instead of this

 

  //#define IR_USE_TIMER1   // tx = pin 9

  #define IR_USE_TIMER2     // tx = pin 3

 

But then compilation failed again:

 

IRremote\IRremote.cpp.o: In function `__vector_11':

D:\Program Files\Arduino\libraries\IRremote/IRremote.cpp:311: multiple definition of `__vector_11'

Servo\Servo.cpp.o:D:\Program Files\Arduino\libraries\Servo/Servo.cpp:103: first defined here

 

I think that both timers (timer1 and timer2) are busy because of the servo and the tone() functions. I don't know what timers are and I don't know how to use IR receptor without change my robot arquitecture.

I'm noob at making robots and I don't know what to do so any help would be appreciated.

Sorry for my english but I don't speak this lenguage very well...

https://www.youtube.com/watch?v=KB23F5sOBRM

You need to add a #ifndef and #define to the section

You need to add a #ifndef and #define to the section of code in each that does something like this:

 

#ifndef VECDEFS

#define VECDEFS

… The vec var defines…

#endif

Add it to these files.

IRremote.cpp

Servo.cpp

 

**I am not a newb, and, I don’t completely follow what you are **

suggesting. :slight_smile:

I know ifndef means if not defined. Are you saying the “…The vec var defines…” are __vector_7 and __vector_11 so far?

So he would add:

#define __vector_7
#define __vector_11

inbetween #define VECDEFS and #endif

if the issues are double #defines

Then, yes you can just do a #ifndef on the __vector_7 and _11 and the VECDEFS would not be needed.

Now, if they are variables, then you have to make a define like I showed before.

 

I don’t know if they are

I don’t know if they are variables or they aren’t because __vector_7 and __vector_11 don’t appear in any code file.

I don’t know if I get it.

I don’t know if I get it. Assuming I have to write:

 #ifndef VECDEFS

#define VECDEFS

#define __vector_7

#define __vector_11

#endif

in IRemote.cpp and in servo.cpp, where should I write this lines into the code?

If I write this at the beginning, errors like this appear in both files:

D:\Program Files\Arduino\libraries\Servo\Servo.cpp:112: error: expected unqualified-id before ‘void’

D:\Program Files\Arduino\libraries\Servo\Servo.cpp:112: error: expected )' before 'void'</p><p>D:\Program Files\Arduino\libraries\Servo\Servo.cpp:112: error: expected unqualified-id before 'void'</p><p>D:\Program Files\Arduino\libraries\Servo\Servo.cpp:112: error: expected )’ before 'void’

I don’t know how to solve this yet, but thanks for help :slight_smile:

 

 

Look in the .cpp and .h for the IRremote and Servo libs.

The error popped there.  

 

You also need to see if they are defined the same thing in both places (I would assume they are)  If they are not, then you will need to rename one in all places in one library.

Look in the header files these libraries include.

I’m away from a Ardunio system for the next two weeks, so can’t look at the code for them.

They are not defined in

They are not defined in these files. Looking at the error messages I think the error popped at .cpp.o files and because of this I don’t find __vector_7 or __vector_11 anywhere, because they are not in any cpp file or h file.

After reading at internet I think the problem is because of using both Arduino timers (timer1 and timer2) and because of trying to use another component which needs use another timer, so I don’t know how to solve it.