c:49: multiple definition of `__vector_23'

I get this error when i try to compile this program:

  study of output of timer2
 timer2 set up as phase and freq correct wave pwm 
 i want to see if changing OCR2B changes the frequency or pulse width.
 My guess is the latter.
 When pulse width, OCR2B is set > 0 two compare matches are made and frequency of the 
 call to interrupt vector is COMPB is 61 hz. if TOIE2 is used the frequency is halved
 to  30 hz. it is also halved if OCR2B is set to 0.
 Changing OCR2B affects the pulse width. top is always FF or 255(not see note. 
 Had WGM22 bit set in the wrong register!!

volatile uint8_t  elx = 100, ars = 0;

void setup() {
   // initialize digital pins 10(Com2a1), 6 as an output.
  pinMode(4, OUTPUT);
  pinMode(6, OUTPUT);
  // initialize serial communication at 9600 bits per second:

  TCCR0A = (1<<COM0B1) | (1<<WGM00); 
  TCCR2B = (1<<WGM02) | (1<<CS02) | (1<<CS01) | (1<<CS00);      //full wave 1/1024th of 16 mHz. 
  TIMSK0 = (1<<TOIE0);   // allow the timer0 to throw an an interrupt
  OCR0A = 125;            // set so that one cycle is 1 ms.
  OCR0B = 60;               // changes pulse width
  interrupts ();

ISR(TIMER0_OVF_vect) {
// increment the time.
if(elx > 0) elx--;	  // calc delay sequence.

void loop() {
  while(elx > 10) {
  // toggle output to pin 6
  ars ^= 1;
  digitalWrite(6, ars);   // turn the LED according to state of ars
  elx = 100;

the entire error message is

Arduino: 1.6.4 (Windows 7), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\BenzigJN\AppData\Local\Temp\build8183585045145922005.tmp/core.a(wiring.c.o): In function `__vector_23':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/wiring.c:49: multiple definition of `__vector_23'
timer0_jun06cb.cpp.o:C:\Program Files (x86)\Arduino/timer0_jun06cb.ino:30: first defined here
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions
collect2.exe: error: ld returned 1 exit status
Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Only does this on Timer0 but not for Timer2. I've read other posts with the similar error and it looks like a bug in the build of this board. Any suggestions to flash a newer version of bootloader? 
Timer0 works fine with OCIE0A and COMPA. - Thanks, j

This is already being used by millis() in wiring.c and so by adding it to your code you are declaring the routine for that vector a second time which is not allowed.

In case you are wondering how I knew that was __vector_23, look at page 101 of the atmega2560 datasheet and you will see all of the interrupt vector names and there number. Subtract 1 from the number in the datasheet and you get the avr-libc __vector_n index (the -1 is because avr-libc uses zero indexing of the vectors whilst the datasheet uses one indexing).

On top of that, your code seems to be about timer 2, but all but one of the registers and bit defines you are changing are related to timer 0.

TCCR0A is timer 0. TCCR2A would be timer 2.
COM0B1 is timer 0. COM2B1 would be timer 2.
and so on…

Timer 0 is used for millis, so if you are planning on using the Arduino core, don’t use Timer 0.

// increment the time.
if(elx > 0) elx--;    // calc delay sequence.

How does subtracting one increment the time?

Hi, all.

I have this problem too.

I made this library: http://www.cyber-place.ru/showthread.php?t=1909 and found that I have the same problem with overriding __vector_23(). Original function millis() explicitly overridden and the original wirimg.c not used (all overridden and/or renamed in the header file).

But, I have this same error about __vector_23() in Arduino IDE 1.01 (installed using aptitude from Linux repository) and can(!) get this error in the IDE Arduino 1.6.4 that was unpacked from this site. Sometimes I don't get this error ... why?

I have 4 install version 1.01 and 1.6.4 on different systems (all Linux debian64 6.x, 7.x, Ubunty64 Ubuntu32 and last) and have different behavior.

If I understand anything, avr-gcc librarier should choose body functions from the library user and not from core.a . Why it doesn't always happen for 1.6.4 and it never occurs to version 1.0.1? Thank you.

Can anybody help me?

Sometimes I have that error for an Arduino Mega 2560 board, when certain optimizations are not possible with a large code size. If the Arduino environment is used properly, that error should not occur. Some users want to use all the timers and interrupts with a lot direct register programmer. For those it is better to use a IDE without Arduino.

Arhat109: Can anybody help me?

If I understand anything, avr-gcc librarier should choose body functions from the library user and not from core.a . Why it doesn't always happen for 1.6.4 and it never occurs to version 1.0.1?

Maybe make a new thread. This is months old. Plus I don't understand what you mean by "core.a".

I thought this topic fit the problem. When we compile the sketch in the IDE, at first will be created a library of standard Wiring with the name core.a, in which is included the result of the compilation of the file "wiring.c". In this file there is a definition of interruption __vector_23() to implement time functions, and in particular millis().

I want have the next in skecthes:

include "arhat.h" // and in it use own __vector_23(), millis() and delay() described in arhat_time.c

but I have this error message instead it.

There are some way to explain to the collector that the interrupt is taken from an additional library (in this named "arhat.h"), and not from the "core.a" (wiring.c)? Or I must rename wiring.c only.

I hope the problem are solved. :)

It is occurs only when I compiled sketches on two installed IDE: v.1.0.1 and 1.6.4 or above. Version 1.0.1 was installed previous from debian repository (please change it!) and after was installed version 1.6.4 above previous. Perhaps, new version are using old definitions from older.

When installed only new version, this problem are not occurs. You may use this library (arhat.h) now as usual. :)