0

The error shown is

C:\Users\SIDDHA~1\AppData\Local\Temp\build3397782103973366883.tmp/core.a(Tone.cpp.o): In function `__vector_7':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Tone.cpp:536: multiple definition of `__vector_7'
C:\Users\SIDDHA~1\AppData\Local\Temp\build3397782103973366883.tmp\IRremote\IRremote.cpp.o:C:\Users\Siddharth Yadav\Documents\Arduino\libraries\IRremote/IRremote.cpp:361: first defined here
collect2.exe: error: ld returned 1 exit status

Error snapshot

Why is this happening?

The code is:

#include <IRremote.h>

const int echo = 7;// connected to ultrasonic sensor's echo
const int trig = 8;// connected to ultrasonic sensor's trig
const int Right1 = 10;
const int Right2 = 11;
const int Left1 = 12;
const int Left2 = 9;// change this to any other pin; except pin 13
const int buzzer = 5;
const int rightIR = 3;// change here
const int leftIR = 2;// change here
int RECV_PIN = 4;
const int forward = 51;
const int backward = 36;
const int left = 19;
const int right = 0;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup() {
  pinMode(buzzer, OUTPUT);
  pinMode(echo, INPUT_PULLUP);
  pinMode(rightIR, INPUT_PULLUP);
  pinMode(leftIR, INPUT_PULLUP);
  pinMode(trig, OUTPUT);
  pinMode(Right1, OUTPUT);
  pinMode(Right2, OUTPUT);
  pinMode(Left1, OUTPUT);
  pinMode(Left2, OUTPUT);
  sing(1);
  Serial.begin(9600);
 irrecv.enableIRIn(); // Start the receiver

}

void loop() {
  digitalWrite(13, HIGH);
  if (calcDistance() > 30 && !isRight() && !isLeft())
  {
    if (irrecv.decode(&results))
    {
      Serial.println(results.value, HEX);
      irrecv.resume(); // Receive the next value
      delay(50);
    }
    else {
      moveForward();
    }

  }
  else
  {
    delay(10);
    int dist = calcDistance();
    if (dist < 30 && isLeft() && isRight())
    {
      Serial.println("Moving backward");
      tone(buzzer, 4699, 10);
      moveBackward();
      delay(1000);
    }
    else if (isLeft())
    {
      turnRight();
      digitalWrite(13, LOW);
      tone(buzzer, 104, 10);
      Serial.println("Turning Right");
    }
    else if (isRight())
    {
      turnLeft();
      digitalWrite(13, LOW);
      delay(300);
      tone(buzzer, 880, 10);
      Serial.println("Turning LEft");
    }
    else if (dist < 30)
    {
      turnRight();
      digitalWrite(13, LOW);
      tone(buzzer,  104 , 10);
      Serial.println("Turning Right");
    }

  }

  delay(20);
}
  • Can you get a more readable shot of the messages? Or cut-and-paste them? This image is pretty difficult to read. – JRobert Apr 22 '15 at 12:07
  • C:\Users\SIDDHA~1\AppData\Local\Temp\build3397782103973366883.tmp/core.a(Tone.cpp.o): In function __vector_7': C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Tone.cpp:536: multiple definition of __vector_7' C:\Users\SIDDHA~1\AppData\Local\Temp\build3397782103973366883.tmp\IRremote\IRremote.cpp.o:C:\Users\Siddharth Yadav\Documents\Arduino\libraries\IRremote/IRremote.cpp:361: first defined here collect2.exe: error: ld returned 1 exit status – iamSiddharthYadav Apr 22 '15 at 12:18
1

As the error message says you have multiple definitions of __vector_7 which is defined in: IRemote.cpp:361 and Tone.cpp:536

Tone.cpp is arduino standart lib. If IRemote is a lib of yours then you should edit the cpp file and change the symbol to sth else.

1

The IRemote.cpp and Tone.cpp would be using the same interrupt vector. I believe it's ISR(TIMER5_COMPA_vect) {

  • You could. I don't think it's the best solution, but go to Tone.cpp and comment the ISR(TIMER5_COMPA_vect) { like /*ISR(TIMER5_COMPA_vect)*/void XunusedX(void) {. And be sure to never use any function from ...

  • You could also try to find a way on how not to invoke Tone.h with core.a. include <Tone.h> could be replaced with //include <Tone.h>

  • You could use another timer in IRRemote.h

  • This answer is better than mine :) – Mert Gülsoy Apr 18 '16 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.