user58235: I have just started with Arduino and C++ so I apologise if my question is very basic. 
I am trying to use tone() with a passive buzzer to create a sound while also using the IRremote library for a remote. However, whenever they are used together, it gives this error:

Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `__vector_7'
libraries\IRremote\IRremote.cpp.o (symbol from plugin):(.text+0x0):
  first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.

This is the code required to recreate this error:
#include "IRremote.h"
#include "pitches.h"
int melody[] = {NOTE_C5, NOTE_E6};

void setup() {}

void loop() {
 for (int thisNote = 0; thisNote < 2; thisNote++) {
 tone(3, melody[thisNote], 300);
}
}

Please could you advise me on how to fix this issue and if necessary, on a different library or way to create a sound or to receive IR signals?

user34529: Exactly as @MichelKeijzers wrote the issue is caused by "IRremote" using same timer as "Tone" and the solution to this problem is a little dirty.
Since Tone is included in ArduinoCore (and compiled) we can't easilly modify it so the only thing that worked for me is to modify boarddefs.h file of IRremote library. Since it's code is easilly available after downloading it using "Library Manager" included in ArduinoIDE.
In my tests I used ATmega328P settings.

Edit C:\Users\youruser\Documents\Arduino\libraries\IRremote\boarddefs.h and look for your processor number.
For ATmega328 the definition is #define IR_USE_TIMER2

I simply changed it to use #define IR_USE_TIMER1

And compilation was successfull.
Sketch uses 2746 bytes (8%) of program storage space. Maximum is 30720 bytes.
Global variables use 242 bytes (11%) of dynamic memory, leaving 1806 bytes for local variables. Maximum is 2048 bytes.

My code:
#include "IRremote.h"

#define NOTE_C5  523
#define NOTE_E6  1319

int melody[] = {NOTE_C5, NOTE_E6};

void setup() {}

void loop() {
  for (int thisNote = 0; thisNote < 2; thisNote++) {
    tone(3, melody[thisNote], 300);
  }
}


58235: <p>I have just started with Arduino and C++ so I apologise if my question is very basic. 
I am trying to use tone() with a passive buzzer to create a sound while also using the IRremote library for a remote. However, whenever they are used together, it gives this error:</p>

<blockquote>
  <p>Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':</p>
  
  <p>(.text+0x0): multiple definition of `__vector_7'</p>
  
  <p>libraries\IRremote\IRremote.cpp.o (symbol from plugin):(.text+0x0):
  first defined here</p>
  
  <p>collect2.exe: error: ld returned 1 exit status</p>
  
  <p>exit status 1</p>
  
  <p>Error compiling for board Arduino/Genuino Uno.</p>
</blockquote>

<p>This is the code required to recreate this error:</p>

<pre class="lang-cpp prettyprint-override"><code>#include "IRremote.h"
#include "pitches.h"
int melody[] = {NOTE_C5, NOTE_E6};

void setup() {}

void loop() {
 for (int thisNote = 0; thisNote &lt; 2; thisNote++) {
 tone(3, melody[thisNote], 300);
}
}
</code></pre>

<p>Please could you advise me on how to fix this issue and if necessary, on a different library or way to create a sound or to receive IR signals?</p>
 34529: <p>Exactly as @MichelKeijzers wrote the issue is caused by "IRremote" using same timer as "Tone" and the solution to this problem is a little dirty.</p>

<p>Since Tone is included in ArduinoCore (and compiled) we can't easilly modify it so the only thing that worked for me is to modify boarddefs.h file of IRremote library. Since it's code is easilly available after downloading it using "Library Manager" included in ArduinoIDE.</p>

<p>In my tests I used ATmega328P settings.</p>

<p><a href="https://i.stack.imgur.com/oATAN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oATAN.png" alt="arduino board setting"></a></p>

<p>Edit <code>C:\Users\youruser\Documents\Arduino\libraries\IRremote\boarddefs.h</code> and look for your processor number.</p>

<p>For ATmega328 the definition is <code>#define IR_USE_TIMER2</code></p>

<p><a href="https://i.stack.imgur.com/9C3he.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9C3he.png" alt="boarddefs.h code"></a></p>

<p>I simply changed it to use #define <code>IR_USE_TIMER1</code></p>

<p><a href="https://i.stack.imgur.com/c0l49.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c0l49.png" alt="boarddefs.h updated"></a></p>

<p>And compilation was successfull.</p>

<pre><code>Sketch uses 2746 bytes (8%) of program storage space. Maximum is 30720 bytes.
Global variables use 242 bytes (11%) of dynamic memory, leaving 1806 bytes for local variables. Maximum is 2048 bytes.
</code></pre>

<p>My code:</p>

<pre><code>#include "IRremote.h"

#define NOTE_C5  523
#define NOTE_E6  1319

int melody[] = {NOTE_C5, NOTE_E6};

void setup() {}

void loop() {
  for (int thisNote = 0; thisNote &lt; 2; thisNote++) {
    tone(3, melody[thisNote], 300);
  }
}
</code></pre>
