[SOLVED] Duplicate symbol error when using NewPing.h and IRremote.h


I’m creating a sketch using an infrared sensor (IRremote) and a ultrasonic distance sensor (NewPing).
When I compile the sketch, I get this duplicate symbol error:

C:…\Temp\arduino_build_48251\libraries\NewPing\NewPing.cpp.o (symbol from plugin): In function `intFunc2’:

(.text+0x0): multiple definition of `__vector_7’

C:…\Temp\arduino_build_48251\libraries\IRremote\IRremote.cpp.o (symbol from plugin):(.text+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

If I switch the order of the #include sentences, logically I get the same error in IRremote.cpp.o (symbol from plugin): In function `MATCH(int, int)’

For instance (!), there is no symbol __vector_7 nor similar in both source codes. This should be a symbol generated internally by the compiler.

I updated both libraries to his latests versions, and the IDE to the latests too (v1.8.8). I have the revised once and again the source code for both NewPing.h and IRremote.h, and even their attached #include files, with no result.

The complete sketch is as simple as:

#include <NewPing.h>
NewPing sonar(11, 12, MAX_SENSOR_DISTANCE);

#include <IRremote.h>
IRrecv irrecv(13);

void setup() {}

void loop() {}

Have you even found this issue? Do you know how can I to solve this?


The New Ping library uses the same timer as the IR library.

Ditch the New Ping is my usual advice.

Edit: Yes, that's exactly what I told you two days ago, when you posted the same question.



Searching for 'vector_7' I found the topic: http://forum.arduino.cc/index.php?topic=133553.0

In that, the user mcremers talks about the sentence:

ISR(TIMER5_COMPA_vect) {...

Then, searching for the text 'ISR(' in the NewPing.cpp source code I found a section where it uses some ISR(TIMER...) sentences. This section is round by a conditional if block as:

#if TIMER_ENABLED == true && DO_BITWISE == true

Then, searching for 'TIMER_ENABLED' I found a reference in the NewPing.h file thay says:

Added TIMER_ENABLED switch to get around compile-time "__vector_7" errors when using the Tone library,

and below:

#define TIMER_ENABLED true // Set to "false" to disable the timer ISR (if getting "__vector_7" compile errors set this to false). Default=true

Well, setting this symbol to false, the sketchs compiles properly.

That's all, folks!