multiple definition of '__vector_7'

I want use buzzle in my code, it can be compiled and linked in scratch2.0, but when i compile in Arduino IDE, it reports multiply redefinition error.
how can i resolve this problem? thank you very much!

#include <Arduino.h>
#include <Wire.h>
#include <Servo.h>
#include <SoftwareSerial.h>
#include <MeOrion.h>

void setup(){
pinMode(9,OUTPUT);
tone(9,262,500);
}

void loop(){}

tone.cpp:538: multiple definition of ‘__vector_7’
…\Arduino\libraries\src/MeIR.cpp:67: first defined here

it’s tone.cpp:

#ifdef USE_TIMER2
ISR(TIMER2_COMPA_vect)
{ <------line 538

if (timer2_toggle_count != 0)
{
// toggle the pin
*timer2_pin_port ^= timer2_pin_mask;

it’s MeIR.cpp:

ISR(TIMER_INTR_NAME)
{ <-------line 67
uint8_t irdata = (uint8_t)digitalRead(2);
// uint32_t new_time = micros();

It’s ok in scratch:

C:\Program Files (x86)\tBlock\Arduino\hardware\tools\avr\bin\avr-g++.exe
-c,-g,-Os,-w,-fno-exceptions,-ffunction-sections,-fdata-sections,-MMD,-mmcu=atmega328p,-DF_CPU=16000000L,-DARDUINO=10605,-DARDUINO_AVR_UNO,-DARDUINO_ARCH_AVR,-IC:\Program Files (x86)\tBlock\Arduino/hardware/arduino/avr/cores/arduino,-IC:\Program Files (x86)\tBlock\Arduino/hardware/arduino/avr/variants/standard,-IC:\Program Files (x86)\tBlock\Arduino/libraries/Servo/src,-IC:\Program Files (x86)\tBlock\Arduino/libraries/Servo,-IC:\Program Files (x86)\tBlock\Arduino/hardware/arduino/avr/libraries/Wire,-IC:\Program Files (x86)\tBlock\Arduino/hardware/arduino/avr/libraries/Wire/utility,-IC:\Program Files (x86)\tBlock\Arduino/hardware/arduino/avr/libraries/SoftwareSerial,-IC:\Program Files (x86)\tBlock\Arduino/libraries/makeblock/src,C:\Program Files (x86)\tBlock\Arduino\hardware\arduino\avr\cores\arduino/Tone.cpp,-o,Tone.cpp.o
C:\Program Files (x86)\tBlock\Arduino\hardware\tools\avr\bin\avr-g++.exe
-c,-g,-Os,-w,-fno-exceptions,-ffunction-sections,-fdata-sections,-MMD,-mmcu=atmega328p,-DF_CPU=16000000L,-DARDUINO=10605,-DARDUINO_AVR_UNO,-DARDUINO_ARCH_AVR,-IC:\Program Files (x86)\tBlock\Arduino/hardware/arduino/avr/cores/arduino,-IC:\Program Files (x86)\tBlock\Arduino/hardware/arduino/avr/variants/standard,-IC:\Program Files (x86)\tBlock\Arduino/libraries/Servo/src,-IC:\Program Files (x86)\tBlock\Arduino/libraries/Servo,-IC:\Program Files (x86)\tBlock\Arduino/hardware/arduino/avr/libraries/Wire,-IC:\Program Files (x86)\tBlock\Arduino/hardware/arduino/avr/libraries/Wire/utility,-IC:\Program Files (x86)\tBlock\Arduino/hardware/arduino/avr/libraries/SoftwareSerial,-IC:\Program Files (x86)\tBlock\Arduino/libraries/makeblock/src,C:\Program Files (x86)\tBlock\Arduino\libraries\makeblock\src/MeIR.cpp,-o,MeIR.cpp.o
C:\Program Files (x86)\tBlock\Arduino\hardware\tools\avr\bin\avr-g++.exe
-c,-g,-Os,-w,-fno-exceptions,-ffunction-sections,-fdata-sections,-MMD,-mmcu=atmega328p,-DF_CPU=16000000L,-DARDUINO=10605,-DARDUINO_AVR_UNO,-DARDUINO_ARCH_AVR,-IC:\Program Files (x86)\tBlock\Arduino/hardware/arduino/avr/cores/arduino,-IC:\Program Files (x86)\tBlock\Arduino/hardware/arduino/avr/variants/standard,-IC:\Program Files (x86)\tBlock\Arduino/libraries/Servo/src,-IC:\Program Files (x86)\tBlock\Arduino/libraries/Servo,-IC:\Program Files (x86)\tBlock\Arduino/hardware/arduino/avr/libraries/Wire,-IC:\Program Files (x86)\tBlock\Arduino/hardware/arduino/avr/libraries/Wire/utility,-IC:\Program Files (x86)\tBlock\Arduino/hardware/arduino/avr/libraries/SoftwareSerial,-IC:\Program Files (x86)\tBlock\Arduino/libraries/makeblock/src,project______c_0_5.ino.cpp,-o,project______c_0_5.ino.o
1-10 15:33: Process exited with 0
C:\Program Files (x86)\tBlock\Arduino\hardware\tools\avr\bin\avr-gcc.exe
-Os,-Wl,–gc-sections,-mmcu=atmega328p,-o,project______c_0_5.ino.elf,project______c_0_5.ino.o,core.a,-L./,-lm
1-10 15:33: Process exited with 0
C:\Program Files (x86)\tBlock\Arduino\hardware\tools\avr\bin\avr-objcopy.exe
-O,ihex,-j,.eeprom,–set-section-flags=.eeprom=alloc,load,–no-change-warnings,–change-section-lma,.eeprom=0,project______c_0_5.ino.elf,project______c_0_5.ino.eep
1-10 15:33: Process exited with 0
C:\Program Files (x86)\tBlock\Arduino\hardware\tools\avr\bin\avr-objcopy.exe
-O,ihex,-R,.eeprom,project______c_0_5.ino.elf,project______c_0_5.ino.hex
1-10 15:33: Process exited with 0

As far as Google tells me Scratch2.0 is an editor. So how can that code compile in that editor? Maybe you forgot the most important information there?

Your MeIR library seems to use timer 2. The Arduino tone() function does make use of timer 2 also. As both try to install an interrupt handler you have a conflict which the Arduino IDE tries to tell you in a slightly non-user-friendly way.

Thank you for your reply. I know it seems there are some comflicts between MeIR and tone(), but i dont know how to find the method that scratch resolved it,so i paste the compile arguments of scratch。Would you help me?

this is the head of MeIR.cpp, This file is a drive for Me IR device, The IR inherited the MeSerial class from SoftwareSerial.

/**

  • \par Copyright (C), 2012-2015, MakeBlock
  • \class MeIR
  • \brief Driver for Me IR module.
  • @file MeIR.cpp
  • @author MakeBlock
  • @version V1.0.0
  • @date 2015/11/09
  • @brief Driver for Me IR module.
  • \par Copyright
  • This software is Copyright (C), 2012-2015, MakeBlock. Use is subject to license \n
  • conditions. The main licensing options available are GPL V2 or Commercial: \n
  • \par Open Source Licensing GPL V2
  • This is the appropriate option if you want to share the source code of your \n
  • application with everyone you distribute it to, and you also want to give them \n
  • the right to share who uses it. If you wish to use this software under Open \n
  • Source Licensing, you must contribute all your source code to the open source \n
  • community in accordance with the GPL Version 2 when your application is \n
  • distributed. See http://www.gnu.org/copyleft/gpl.html
  • \par Description
  • This file is a drive for Me IR device, The IR inherited the
  • MeSerial class from SoftwareSerial.
  • \par Method List:
    1. ErrorStatus MeIR::decode();
    1. void MeIR::begin();
    1. void MeIR::end();
    1. void MeIR::loop();
    1. boolean MeIR::keyPressed(unsigned char r);
    1. String MeIR::getString();
    1. unsigned char MeIR::getCode()
    1. void MeIR::sendString(String s);
    1. void MeIR::sendString(float v);
    1. void MeIR::sendNEC(unsigned long data, int nbits);
    1. void MeIR::sendRaw(unsigned int buf, int len, uint8_t hz);
    1. void MeIR::enableIROut(uint8_t khz);
    1. void MeIR::enableIRIn();
    1. void MeIR::mark(uint16_t us);
    1. void MeIR::space(uint16_t us);
  • \par History:
  • 
    
  • <Author> <Time> <Version> <Descr>
  • forfish 2015/11/09 1.0.0 Add description

*/

Isnt that timer1 not timer2?

I thought tone used the good timer (which is timer1, the 16-bit timer found on most classic avrs js NY far the most useful timer - the bigger chips have a couple more just like it as timer 3/4/5, and the t841 has a second good one named timer2)

But yeah, modifying the library to use a different timer will require considerable effort from someone who is familiar with the operation of the timers on the avr product line and the intended behavior of that library.

There is a tone library that uses the other timer already written. Use that

I thought tone used the good timer (which is timer1, the 16-bit timer found on most classic avrs

No, at least in the current IDE timer 2 is used for most AVRs.

I know it seems there are some comflicts between MeIR and tone(), but i dont know how to find the method that scratch resolved it,so i paste the compile arguments of scratch。

As far as I can see it didn't solve it. It just compiled the files but it never linked them. But it's hard to read command lines if all white-space is eliminated.

If you just want to play one sound you don't need the timer, just use that timer free tone library:

https://bitbucket.org/teckel12/arduino-timer-free-tone/wiki/Home