Error compiling modified Multiwii code

Hello everyone, I want to compile this modified version of multiwii.

First of all, after I unzip the archive, When I want to open "MultiWii_2.4.2.ino", Arduino IDE tells me that it should be in a folder with "MultiWii_2.4.2" name, and I click on yes, and then I move all other files to the newly created folder.

Then in the config.h file, these are the changes that I do:

*Commenting this line: #define QUADX
*Uncommenting this line: #define FLYING_WING
*Uncommenting this line: #define GY_521

And I choose Arduino Nano as my board from tools menu of Arduino IDE

And I get this error message when I want to compile the code:

redefinition of 'void __vector_14()'

Here is the complete message:

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\erfan\AppData\Local\Arduino15\packages -hardware C:\Users\erfan\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\erfan\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\erfan\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10815 -build-path C:\Users\erfan\AppData\Local\Temp\arduino_build_508139 -warnings=none -build-cache C:\Users\erfan\AppData\Local\Temp\arduino_cache_155457 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avrdude.path=C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.arduinoOTA.path=C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -verbose C:\Users\erfan\Desktop\MultiWii-Nrf24l01-SingleBoard-main\MultiWii-Nrf24l01-SingleBoard-main\MultiWii+Nrf+BMP280\MultiWii_2.4.2\MultiWii_2.4.2.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\erfan\AppData\Local\Arduino15\packages -hardware C:\Users\erfan\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\erfan\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\erfan\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10815 -build-path C:\Users\erfan\AppData\Local\Temp\arduino_build_508139 -warnings=none -build-cache C:\Users\erfan\AppData\Local\Temp\arduino_cache_155457 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avrdude.path=C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.arduinoOTA.path=C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -verbose C:\Users\erfan\Desktop\MultiWii-Nrf24l01-SingleBoard-main\MultiWii-Nrf24l01-SingleBoard-main\MultiWii+Nrf+BMP280\MultiWii_2.4.2\MultiWii_2.4.2.ino
Using board 'nano' from platform in folder: C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3
Using core 'arduino' from platform in folder: C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3
Detecting libraries used...
"C:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "C:\\Users\\erfan\\AppData\\Local\\Temp\\arduino_build_508139\\sketch\\MultiWii_2.4.2.ino.cpp" -o nul
Using cached library dependencies for file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\Alarms.cpp
Using cached library dependencies for file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\EEPROM.cpp
Using cached library dependencies for file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\GPS.cpp
Using cached library dependencies for file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\IMU.cpp
Using cached library dependencies for file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\LCD.cpp
Using cached library dependencies for file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\MultiWii.cpp
Using cached library dependencies for file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\NRF24_RX.cpp
Alternatives for RF24.h: [RF24@1.4.1 RF24-master@1.1.5]
ResolveLibrary(RF24.h)
  -> candidates: [RF24@1.4.1 RF24-master@1.1.5]
Alternatives for SPI.h: [SPI@1.0]
ResolveLibrary(SPI.h)
  -> candidates: [SPI@1.0]
"C:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\Users\\erfan\\Documents\\Arduino\\libraries\\RF24" "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "C:\\Users\\erfan\\AppData\\Local\\Temp\\arduino_build_508139\\sketch\\Output.cpp" -o nul
Using cached library dependencies for file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\Protocol.cpp
Using cached library dependencies for file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\RX.cpp
Using cached library dependencies for file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\Sensors.cpp
Using cached library dependencies for file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\Serial.cpp
"C:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\Users\\erfan\\Documents\\Arduino\\libraries\\RF24" "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "-IC:\\Users\\erfan\\Documents\\Arduino\\libraries\\RF24\\utility" "C:\\Users\\erfan\\Documents\\Arduino\\libraries\\RF24\\RF24.cpp" -o nul
"C:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\Users\\erfan\\Documents\\Arduino\\libraries\\RF24" "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "C:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src\\SPI.cpp" -o nul
Generating function prototypes...
"C:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\Users\\erfan\\Documents\\Arduino\\libraries\\RF24" "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "C:\\Users\\erfan\\AppData\\Local\\Temp\\arduino_build_508139\\sketch\\MultiWii_2.4.2.ino.cpp" -o "C:\\Users\\erfan\\AppData\\Local\\Temp\\arduino_build_508139\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\erfan\\AppData\\Local\\Temp\\arduino_build_508139\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\Users\\erfan\\Documents\\Arduino\\libraries\\RF24" "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "C:\\Users\\erfan\\AppData\\Local\\Temp\\arduino_build_508139\\sketch\\MultiWii_2.4.2.ino.cpp" -o "C:\\Users\\erfan\\AppData\\Local\\Temp\\arduino_build_508139\\sketch\\MultiWii_2.4.2.ino.cpp.o"
Using previously compiled file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\NRF24_RX.cpp.o
Using previously compiled file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\LCD.cpp.o
Using previously compiled file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\MultiWii.cpp.o
"C:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\Users\\erfan\\Documents\\Arduino\\libraries\\RF24" "-IC:\\Users\\erfan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "C:\\Users\\erfan\\AppData\\Local\\Temp\\arduino_build_508139\\sketch\\Output.cpp" -o "C:\\Users\\erfan\\AppData\\Local\\Temp\\arduino_build_508139\\sketch\\Output.cpp.o"
Using previously compiled file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\Alarms.cpp.o
Using previously compiled file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\EEPROM.cpp.o
Using previously compiled file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\IMU.cpp.o
Using previously compiled file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\GPS.cpp.o
Using previously compiled file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\RX.cpp.o
Using previously compiled file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\Sensors.cpp.o
Using previously compiled file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\Protocol.cpp.o
Using previously compiled file: C:\Users\erfan\AppData\Local\Temp\arduino_build_508139\sketch\Serial.cpp.o
In file included from C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\cores\arduino/Arduino.h:30:0,
                 from C:\Users\erfan\Desktop\MultiWii-Nrf24l01-SingleBoard-main\MultiWii-Nrf24l01-SingleBoard-main\MultiWii+Nrf+BMP280\MultiWii_2.4.2\Output.cpp:1:
C:\Users\erfan\Desktop\MultiWii-Nrf24l01-SingleBoard-main\MultiWii-Nrf24l01-SingleBoard-main\MultiWii+Nrf+BMP280\MultiWii_2.4.2\Output.cpp: In function 'void __vector_14()':
Output.cpp:1013:27: error: redefinition of 'void __vector_14()'
     #define SOFT_PWM_ISR2 TIMER0_COMPA_vect
                           ^
C:\Users\erfan\Desktop\MultiWii-Nrf24l01-SingleBoard-main\MultiWii-Nrf24l01-SingleBoard-main\MultiWii+Nrf+BMP280\MultiWii_2.4.2\Output.cpp:1074:9: note: in expansion of macro 'SOFT_PWM_ISR2'
     ISR(SOFT_PWM_ISR2) {
         ^~~~~~~~~~~~~
C:\Users\erfan\Desktop\MultiWii-Nrf24l01-SingleBoard-main\MultiWii-Nrf24l01-SingleBoard-main\MultiWii+Nrf+BMP280\MultiWii_2.4.2\Output.cpp:760:25: note: 'void __vector_14()' previously defined here
       #define SERVO_ISR TIMER0_COMPA_vect
                         ^
C:\Users\erfan\Desktop\MultiWii-Nrf24l01-SingleBoard-main\MultiWii-Nrf24l01-SingleBoard-main\MultiWii+Nrf+BMP280\MultiWii_2.4.2\Output.cpp:932:7: note: in expansion of macro 'SERVO_ISR'
   ISR(SERVO_ISR) {
       ^~~~~~~~~
Multiple libraries were found for "RF24.h"
 Used: C:\Users\erfan\Documents\Arduino\libraries\RF24
 Not used: C:\Users\erfan\Documents\Arduino\libraries\RF24-master
Using library RF24 at version 1.4.1 in folder: C:\Users\erfan\Documents\Arduino\libraries\RF24 
Using library SPI at version 1.0 in folder: C:\Users\erfan\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries\SPI 
exit status 1
redefinition of 'void __vector_14()'

I couldn't understand what is wrong.

Thank you so much in advance for your help.

Multiple libraries are trying to use the same interrupt

Thanks a lot, I actually visited that topic but unfortunately couldn't understand how to solve this :frowning:

And I still haven't figured out!

In the file that seems to have the bug (ouput.cpp), I found this if statement:

  #if defined(SERVO_1_HIGH)
    #if defined(PROMINI) || (defined(PROMICRO) && defined(HWPWM6)) // uses timer 0 Comperator A (8 bit)
      TCCR0A = 0; // normal counting mode
      TIMSK0 |= (1<<OCIE0A); // Enable CTC interrupt
      #define SERVO_ISR TIMER0_COMPA_vect
      #define SERVO_CHANNEL OCR0A
      #define SERVO_1K_US 250
    #endif

If I comment the line #define SERVO_ISR TIMER0_COMPA_vect , It compiles without any error, but it seems that those lines are necessary and I can't just comment and get rid of them since I will be uploading the code to a Arduino Pro mini. What should I do now?

Yes, both libraries are trying to use the Timer0 CompA interrupt. You will have to edit one of the libraries to use a different one. Just commenting it out won't work. Since a Nano only have 1 16 bit timer (timer1) the easiest way would be to move to a Mega 2560 which has multiple 16 bit timers and then edit the library to use timer5 (or any other 16 bit timer).
Not a trivial task...

Thank you so much, well, how can I solve this problem without moving to a Arduino Mega? I want to use a Arduino pro mini because of its size and weight, as I'm going to use it as a flight controller.

Then you will have to move one of them to Timer2, which is an 8 bit timer. This means you will have to handle periods greater than 255 differently. I would suggest some serious study of the '328 datasheet where they discuss all the timers...

Again, not an easy task...

You know why I guess there should be an easier solution, because if I uncomment //#define QUADX and comment #define FLYING_WING , Then it will compile without any errors, And a quadcopter has 4 main inputs (throttle, pitch, yaw, roll), and 4 main outputs (4motors).
For the Flying wing I want to build, there is also those 4 inputs, and only 3 outputs which are throttle, and two servos, so I guess there could be an easier way to edit this code for a simple flying wing. Maybe servo library is what is causing this error?

I am the repository owner and looked into the matter and would like to ask why are you compiling for nano when you're planning to use with a pro mini.

Let me clear some topics that'll help you,

  1. Your Flying Wing will have enough power to lift a few grams of arduino mega.

  2. Personally I used this code with an uno so no issues for smaller boards in computing it seems.

  3. Pro mini uses atmega 328 same as uno but is smaller in size due to variety of factors not due to chip power so no problem here also it seems.

Now my personal recommendations for your case:

  1. Don't select any combined imu board and just uncomment the sensors you are using and compile its by default for atmega328.

  2. For size you can design your own pcb and use a bare minimal configuration.

Above all ,I have modified multiwii code specially for airplanes also .You'll find them in the same GitHub account here. I suggest better try using the special version.

Happy Flying