Compilation error when using "tone()"

Hello! So, my code works just fine and doesn't get any compilation errors, but when I write tone(7, 1000, 100), I get many compilation errors including this: "Multiple libraries were found for "IRremote.h" ", which has nothing to do with "tone()" :o.

Do you have any ideas? Does there exist sound generating function other than tone()? (By sound generating function I mean a function that can run in parallel with the code).

Do you have any ideas?

Not without seeing the full code and full error message

Full code is so big, I can’t fit it here, so I’ll attach it :smiley:

nice_thing_with_display_and_remoteeee.ino (8.86 KB)

Error messages?

Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp: In member function 'char* DS3231::getDOWStr(uint8_t)':

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:275:17: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

char *output = "xxxxxxxxxx";

^~~~~~~~~~~~

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:276:99: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

char *daysLong[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

^

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:276:99: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:276:99: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:276:99: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:276:99: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:276:99: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:276:99: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:277:70: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

char *daysShort[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};

^

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:277:70: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:277:70: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:277:70: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:277:70: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:277:70: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:277:70: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp: In member function 'char* DS3231::getMonthStr(uint8_t)':

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:289:16: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

char *output= "xxxxxxxxx";

^~~~~~~~~~~

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:290:144: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

char *monthLong[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

^

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:290:144: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:290:144: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:290:144: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:290:144: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:290:144: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:290:144: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:290:144: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:290:144: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:290:144: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:290:144: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:290:144: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:291:106: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

char *monthShort[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};

^

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:291:106: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:291:106: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:291:106: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:291:106: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:291:106: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:291:106: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:291:106: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:291:106: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:291:106: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:291:106: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\Nacho\Documents\Arduino\libraries\DS3231\DS3231.cpp:291:106: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':

(.text+0x0): multiple definition of `__vector_13'

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

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "DS3231.h" Used: C:\Users\Nacho\Documents\Arduino\libraries\DS3231 Multiple libraries were found for "LiquidCrystal.h" Used: C:\Program Multiple libraries were found for "IRremote.h" Used: C:\Users\Nacho\Documents\Arduino\libraries\IRremote exit status 1 Error compiling for board Arduino/Genuino Mega or Mega 2560.

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

This is your error

Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':

(.text+0x0): multiple definition of `__vector_13'

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

You will need to hack one of the libraries to use another timer. I posted a description for the approach how to hack th IRremote library in this thread. Note that the file where you find the stuff depends on the version of the library; for later versions it changed to boarddefs.h.

sterretje, thank you so much! The problem is fixed :grinning: (but in my version of library, "IR_USE_TIMER2" was defined in "boarddefs.h" file).

P.S. Your research is stunning :o, you're a genius! :grin: