Error compiling for board Arduino/Genuino Mega or Mega 2560.

Not sure what happened with this. I had it compiling and now it will not. Any help would be great guys:)

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

sketch\Marlin_main.cpp: In function 'set_probe_deployed':

sketch\Marlin_main.cpp:2307:3: internal compiler error: Segmentation fault

}

^

Please submit a full bug report,

with preprocessed source if appropriate.

See http://gcc.gnu.org/bugs.html for instructions.

lto-wrapper.exe: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/program files/windowsapps/arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

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 bug is specific to the 5.4.0-atmel3.6.1-arduino2 version of avr-gcc used by Arduino AVR Boards 1.6.22 and newer. It has been reported here:
~~Issues · arduino/Arduino · GitHub
Here's the traditional workaround:

  • Tools > Board > Boards Manager
  • Wait for downloads to finish.
  • When you move the mouse pointer over "Arduino AVR Boards", you will see a "Select version" dropdown menu appear. Select "1.6.21".
  • Click "Install".
  • Wait for installation to finish.
  • Click "Close".

If you have File > Preferences > Check for updates on startup checked, the Arduino IDE may occasionally notify you that a new version of Arduino AVR Boards is available, you'll need to refrain from updating back to the new Arduino AVR Boards version, otherwise you'll be back to seeing the segmentation fault error again.

EDITED TO ADD MODERN INSTRUCTIONS:

This bug is specific to the 5.4.0-atmel3.6.1-arduino2 version of avr-gcc used by Arduino AVR Boards 1.6.22 through 1.8.9. It has been reported here:

Here's the fix:

  1. Select Tools > Board > Boards Manager from the Arduino IDE's menus.
  2. Wait for downloads to finish.
  3. From the list of boards platforms, click "Arduino AVR Boards".
  4. Click the Update button.
  5. Wait for installation to finish.
  6. Click Close.
3 Likes

I thought I was going crazy! Ha ha ha:) Thanks for the info and the help. That worked!

1 Like

You're welcome. This bug also drove me crazy when I first encountered it. I was trying to produce a minimal demonstration sketch so I could submit a bug report to Arduino but the bug comes and goes without rhyme or reason. I'm glad to hear it's working for you now. Enjoy!
Per

Yeah, one min it was compiling and I go into my code to make some miner changes and I then recompile and it has not worked. It's been 2 weeks of trying to compile! Ha ha ha:)

I am new to 3D printing and I am having this same issue. I have a CR-10S and Marlin, I am trying to get my BLTouch installed but continuously get that same error I tried doing what is above but I have no luck. What am I doing wrong?

@ravenccpl, those instructions were written a year ago. Since that time, a new version of Arduino AVR Boards was released that fixes the bug. So my new advice for people getting this "lto1.exe: internal compiler error: Segmentation fault" error is to update to the latest version of Arduino AVR Boards:

  1. Select Tools > Board > Boards Manager from the Arduino IDE's menus.
  2. Wait for the updates to finish.
  3. From the list of boards platforms, click "Arduino AVR Boards".
  4. Click the Update button.
  5. Wait for installation to finish.
  6. Click the Close button.

ravenccp1:
I am new to 3D printing and I am having this same issue. I have a CR-10S and Marlin, I am trying to get my BLTouch installed but continuously get that same error I tried doing what is above but I have no luck. What am I doing wrong?

homescienceideas:
Not sure what happened with this. I had it compiling and now it will not. Any help would be great guys:)

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

sketch\Marlin_main.cpp: In function 'set_probe_deployed':

sketch\Marlin_main.cpp:2307:3: internal compiler error: Segmentation fault

}

I had a problem that was pretty similar, I was just uploading and editing my program, doing some changes, but not on a 3D printer. I made a backup in the same directory and when I uploaded it just failed to compile, showing that same error. My fix was eventually I realized some of the warnings were regarding my backup, so don't put backups or other programs in the same directory!!! It kept confusing me and the problem was it was trying to upload both at the same time and also the name for the backup was invalid, it was just a mess. So that was my solution, if the first doesn't work

^

Please submit a full bug report,

with preprocessed source if appropriate.

See http://gcc.gnu.org/bugs.html for instructions.

lto-wrapper.exe: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/program files/windowsapps/arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

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.

homescienceideas:
Not sure what happened with this. I had it compiling and now it will not. Any help would be great guys:)

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

sketch\Marlin_main.cpp: In function 'set_probe_deployed':

sketch\Marlin_main.cpp:2307:3: internal compiler error: Segmentation fault

}

^

Please submit a full bug report,

with preprocessed source if appropriate.

See http://gcc.gnu.org/bugs.html for instructions.

lto-wrapper.exe: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/program files/windowsapps/arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

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.

pert:
This bug is specific to the 5.4.0-atmel3.6.1-arduino2 version of avr-gcc used by Arduino AVR Boards 1.6.22 and newer. It has been reported here:
~~Issues · arduino/Arduino · GitHub
Here's the traditional workaround:

  • Tools > Board > Boards Manager
  • Wait for downloads to finish.
  • When you move the mouse pointer over "Arduino AVR Boards", you will see a "Select version" dropdown menu appear. Select "1.6.21".
  • Click "Install".
  • Wait for installation to finish.
  • Click "Close".

If you have File > Preferences > Check for updates on startup checked, the Arduino IDE may occasionally notify you that a new version of Arduino AVR Boards is available, you'll need to refrain from updating back to the new Arduino AVR Boards version, otherwise you'll be back to seeing the segmentation fault error again.

EDITED TO ADD MODERN INSTRUCTIONS:

This bug is specific to the 5.4.0-atmel3.6.1-arduino2 version of avr-gcc used by Arduino AVR Boards 1.6.22 through 1.8.9. It has been reported here:
IDE 1.8.6 - SD-Lib "Datalogger" - segmentation fault · Issue #7949 · arduino/Arduino · GitHub

Here's the fix:

  • Tools > Board > Boards Manager
  • Wait for downloads to finish.
  • From the list of boards platforms, click "Arduino AVR Boards".
  • Click the "Update" button.
  • Wait for installation to finish.
  • Click "Close".

I get the same code error for compiling. i tryed all the steps and still getting the same error

MakerSpaceYT:
I get the same code error for compiling. i tryed all the steps and still getting the same error

Please do this:

  • (In the Arduino IDE) click File > Preferences
  • Check the box next to "Show verbose output during: > compilation
  • Click "OK"
  • Sketch > Verify/Compile
  • After the compilation fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the compilation output between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.

If the length of the output exceeds the forum's 9000 character limit, save it in a .txt file and post it here as an attachment. If you click the "Reply" button you'll see the "Attachments and other options" link that will allow you to make the attachment.

I recently got a mega 2560 board, and have experienced this error after updating the AVR thing in boards manager. here's my error.

Arduino: 1.8.13 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"





















C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\camer\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\camer\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\camer\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -vid-pid=2341_0042 -ide-version=10813 -build-path C:\Users\camer\AppData\Local\Temp\arduino_build_698461 -warnings=none -build-cache C:\Users\camer\AppData\Local\Temp\arduino_cache_619537 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\camer\Documents\Electronic Engineering\Arduino Sketches\Making_RGB_LEDs_work\Making_RGB_LEDs_work.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\camer\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\camer\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\camer\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -vid-pid=2341_0042 -ide-version=10813 -build-path C:\Users\camer\AppData\Local\Temp\arduino_build_698461 -warnings=none -build-cache C:\Users\camer\AppData\Local\Temp\arduino_cache_619537 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\camer\Documents\Electronic Engineering\Arduino Sketches\Making_RGB_LEDs_work\Making_RGB_LEDs_work.ino

Using board 'mega' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Detecting libraries used...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/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=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Users\\camer\\AppData\\Local\\Temp\\arduino_build_698461\\sketch\\Making_RGB_LEDs_work.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE

Generating function prototypes...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/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=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Users\\camer\\AppData\\Local\\Temp\\arduino_build_698461\\sketch\\Making_RGB_LEDs_work.ino.cpp" -o "C:\\Users\\camer\\AppData\\Local\\Temp\\arduino_build_698461\\preproc\\ctags_target_for_gcc_minus_e.cpp" -DARDUINO_LIB_DISCOVERY_PHASE

"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\\camer\\AppData\\Local\\Temp\\arduino_build_698461\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/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=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Users\\camer\\AppData\\Local\\Temp\\arduino_build_698461\\sketch\\Making_RGB_LEDs_work.ino.cpp" -o "C:\\Users\\camer\\AppData\\Local\\Temp\\arduino_build_698461\\sketch\\Making_RGB_LEDs_work.ino.cpp.o"

In file included from C:\Users\camer\AppData\Local\Temp\arduino_build_698461\sketch\Making_RGB_LEDs_work.ino.cpp:1:0:

C:\Users\camer\Documents\Electronic Engineering\Arduino Sketches\Making_RGB_LEDs_work\Making_RGB_LEDs_work.ino: In function 'void loop()':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:41:14: error: lvalue required as left operand of assignment

 #define LOW  0x0

              ^

C:\Users\camer\Documents\Electronic Engineering\Arduino Sketches\Making_RGB_LEDs_work\Making_RGB_LEDs_work.ino:28:27: note: in expansion of macro 'LOW'

   if (digitalRead(pushR = LOW))

                           ^~~

exit status 1

Error compiling for board Arduino Mega or Mega 2560.

Some assistance with this would be awesome!
Thanks all.

I'll suggest some reference pages for you to study:

If you read all those and then review your sketch, I think the fix will be clear to you.

1 Like

Well I'm not exactly surprised that its user error, but thank you for the resources.

You're welcome. I'm glad if I was able to be of assistance. Enjoy!
Per

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

C:\Users\OTC Engineering\Desktop\al files\OTC PROJECT\PROJECT 2019\OTC\ARDUINO\arduino-1.8.9\arduino-builder -dump-prefs -logger=machine -hardware C:\Users\OTC Engineering\Desktop\al files\OTC PROJECT\PROJECT 2019\OTC\ARDUINO\arduino-1.8.9\hardware -hardware C:\Users\OTC Engineering\AppData\Local\Arduino15\packages -tools C:\Users\OTC Engineering\Desktop\al files\OTC PROJECT\PROJECT 2019\OTC\ARDUINO\arduino-1.8.9\tools-builder -tools C:\Users\OTC Engineering\Desktop\al files\OTC PROJECT\PROJECT 2019\OTC\ARDUINO\arduino-1.8.9\hardware\tools\avr -tools C:\Users\OTC Engineering\AppData\Local\Arduino15\packages -built-in-libraries C:\Users\OTC Engineering\Desktop\al files\OTC PROJECT\PROJECT 2019\OTC\ARDUINO\arduino-1.8.9\libraries -libraries C:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -vid-pid=0X2341_0X0042 -ide-version=10809 -build-path C:\Users\OTCENG~1\AppData\Local\Temp\arduino_build_127204 -warnings=none -build-cache C:\Users\OTCENG~1\AppData\Local\Temp\arduino_cache_807938 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.avrdude-6.3.0-arduino9.path=C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.arduinoOTA.path=C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.1.1 -prefs=runtime.tools.arduinoOTA-1.1.1.path=C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.1.1 -prefs=runtime.tools.avr-gcc.path=C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -prefs=runtime.tools.avr-gcc-4.9.2-atmel3.5.4-arduino2.path=C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -verbose C:\Users\OTC Engineering\Documents\Arduino\rotary_encoder_control_plant\rotary_encoder_control_plant.ino
C:\Users\OTC Engineering\Desktop\al files\OTC PROJECT\PROJECT 2019\OTC\ARDUINO\arduino-1.8.9\arduino-builder -compile -logger=machine -hardware C:\Users\OTC Engineering\Desktop\al files\OTC PROJECT\PROJECT 2019\OTC\ARDUINO\arduino-1.8.9\hardware -hardware C:\Users\OTC Engineering\AppData\Local\Arduino15\packages -tools C:\Users\OTC Engineering\Desktop\al files\OTC PROJECT\PROJECT 2019\OTC\ARDUINO\arduino-1.8.9\tools-builder -tools C:\Users\OTC Engineering\Desktop\al files\OTC PROJECT\PROJECT 2019\OTC\ARDUINO\arduino-1.8.9\hardware\tools\avr -tools C:\Users\OTC Engineering\AppData\Local\Arduino15\packages -built-in-libraries C:\Users\OTC Engineering\Desktop\al files\OTC PROJECT\PROJECT 2019\OTC\ARDUINO\arduino-1.8.9\libraries -libraries C:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -vid-pid=0X2341_0X0042 -ide-version=10809 -build-path C:\Users\OTCENG~1\AppData\Local\Temp\arduino_build_127204 -warnings=none -build-cache C:\Users\OTCENG~1\AppData\Local\Temp\arduino_cache_807938 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.avrdude-6.3.0-arduino9.path=C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.arduinoOTA.path=C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.1.1 -prefs=runtime.tools.arduinoOTA-1.1.1.path=C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.1.1 -prefs=runtime.tools.avr-gcc.path=C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -prefs=runtime.tools.avr-gcc-4.9.2-atmel3.5.4-arduino2.path=C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -verbose C:\Users\OTC Engineering\Documents\Arduino\rotary_encoder_control_plant\rotary_encoder_control_plant.ino
Using board 'mega' from platform in folder: C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21
Using core 'arduino' from platform in folder: C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21
WARNING: Category 'Device, Control, RTC, wifi, ethernet' in library DS323x_Generic is not valid. Setting to 'Uncategorized'
Build options changed, rebuilding all
Detecting libraries used...
"C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10809 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "C:\Users\OTCENG~1\AppData\Local\Temp\arduino_build_127204\sketch\rotary_encoder_control_plant.ino.cpp" -o nul
"C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10809 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\arduino_459402" "C:\Users\OTCENG~1\AppData\Local\Temp\arduino_build_127204\sketch\rotary_encoder_control_plant.ino.cpp" -o nul
"C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10809 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\arduino_459402" "-IC:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\LiquidCrystal_I2C" "C:\Users\OTCENG~1\AppData\Local\Temp\arduino_build_127204\sketch\rotary_encoder_control_plant.ino.cpp" -o nul
"C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10809 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\arduino_459402" "-IC:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\LiquidCrystal_I2C" "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire\src" "C:\Users\OTCENG~1\AppData\Local\Temp\arduino_build_127204\sketch\rotary_encoder_control_plant.ino.cpp" -o nul
"C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10809 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\arduino_459402" "-IC:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\LiquidCrystal_I2C" "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire\src" "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\EEPROM\src" "C:\Users\OTCENG~1\AppData\Local\Temp\arduino_build_127204\sketch\rotary_encoder_control_plant.ino.cpp" -o nul
"C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10809 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\arduino_459402" "-IC:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\LiquidCrystal_I2C" "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire\src" "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\EEPROM\src" "C:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\arduino_459402\DHT.cpp" -o nul
"C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10809 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\arduino_459402" "-IC:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\LiquidCrystal_I2C" "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire\src" "-IC:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\EEPROM\src" "C:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\arduino_459402\DHT_U.cpp" -o nul
In file included from C:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\arduino_459402\DHT_U.cpp:15:0:

C:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\arduino_459402\DHT_U.h:36:29: fatal error: Adafruit_Sensor.h: No such file or directory

#include <Adafruit_Sensor.h>

                         ^

compilation terminated.

Using library arduino_459402 at version 1.3.8 in folder: C:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\arduino_459402
Using library LiquidCrystal_I2C at version 1.1.2 in folder: C:\Users\OTC Engineering\Documents\Arduino\libraries\Hmi\libraries\LiquidCrystal_I2C
Using library Wire at version 1.0 in folder: C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire
Using library EEPROM at version 2.0 in folder: C:\Users\OTC Engineering\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\EEPROM
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

I'm no Arduino expert and please don't go any further with my advice if someone more experienced can reply, but to my knowledge #include <LibraryName.h> will require a fully updated version of whatever library you are planning to use, right? Check if you can find and update the library "Adafruit Sensor" in the Library Manager or online.

And speaking of, I have my own problem with the my Mega 2560.

Arduino: 1.8.10 (Mac OS X), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/shloakmenon/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/shloakmenon/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/shloakmenon/Documents/Arduino/libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -vid-pid=0X2341_0X0042 -ide-version=10810 -build-path /var/folders/1x/025_703d74q461t_stvkxxk80000gp/T/arduino_build_701358 -warnings=none -build-cache /var/folders/1x/025_703d74q461t_stvkxxk80000gp/T/arduino_cache_325484 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=/Users/shloakmenon/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.1.1 -prefs=runtime.tools.arduinoOTA-1.1.1.path=/Users/shloakmenon/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.1.1 -prefs=runtime.tools.avrdude.path=/Users/shloakmenon/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9 -prefs=runtime.tools.avrdude-6.3.0-arduino9.path=/Users/shloakmenon/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9 -prefs=runtime.tools.avr-gcc.path=/Users/shloakmenon/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2 -prefs=runtime.tools.avr-gcc-4.9.2-atmel3.5.4-arduino2.path=/Users/shloakmenon/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2 -verbose /Users/shloakmenon/Documents/Arduino/servoTest/servoTest.ino
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/shloakmenon/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/shloakmenon/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/shloakmenon/Documents/Arduino/libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -vid-pid=0X2341_0X0042 -ide-version=10810 -build-path /var/folders/1x/025_703d74q461t_stvkxxk80000gp/T/arduino_build_701358 -warnings=none -build-cache /var/folders/1x/025_703d74q461t_stvkxxk80000gp/T/arduino_cache_325484 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=/Users/shloakmenon/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.1.1 -prefs=runtime.tools.arduinoOTA-1.1.1.path=/Users/shloakmenon/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.1.1 -prefs=runtime.tools.avrdude.path=/Users/shloakmenon/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9 -prefs=runtime.tools.avrdude-6.3.0-arduino9.path=/Users/shloakmenon/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9 -prefs=runtime.tools.avr-gcc.path=/Users/shloakmenon/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2 -prefs=runtime.tools.avr-gcc-4.9.2-atmel3.5.4-arduino2.path=/Users/shloakmenon/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2 -verbose /Users/shloakmenon/Documents/Arduino/servoTest/servoTest.ino
Using board 'mega' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr
Using core 'arduino' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr
Detecting libraries used...
/Users/shloakmenon/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/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=atmega2560 -DF_CPU=16000000L -DARDUINO=10810 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/mega /var/folders/1x/025_703d74q461t_stvkxxk80000gp/T/arduino_build_701358/sketch/servoTest.ino.cpp -o /dev/null
fork/exec /Users/shloakmenon/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++: bad CPU type in executable
Error compiling for board Arduino/Genuino Mega or Mega 2560.

Please someone help, thanks!

A post was split to a new topic: Avrdude: stk500_recv(): programmer is not responding (mark_25)

2 posts were merged into an existing topic: Help! Error compiling for board Arduino Mega or Mega 2560

I had the same issue with my program. I tried all of these steps but was in vain. Then I copied it and pasted it into a new file and it worked absolutely fine.