Upload/ Compile Error

Hi all, I am receiving this upload? compile error and I do not know what I should do to fix it. I will add the error below:

sing board 'uno' from platform in folder: C:\Users\Dean\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3
Using core 'arduino' from platform in folder: C:\Users\Dean\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3
Detecting libraries used...
"C:\Users\Dean\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=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\Dean\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\cores\arduino" "-IC:\Users\Dean\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\variants\standard" "C:\Users\Dean\AppData\Local\Temp\arduino-sketch-1C4369200C494E02E137224A20F13BD7\sketch\sketch_mar29b.ino.cpp" -o nul
Alternatives for Servo.h: []
ResolveLibrary(Servo.h)
-> candidates: []
Compilation error: Error: 2 UNKNOWN: exit status 1

If anyone knows how to fix this issue please let me know :slight_smile:

Hi @deandriver. This error is caused by not having a library installed that your sketch uses.

In this case, that might be confusing because we are accustomed to the Servo library always being available. The reason it's not now is because, unlike the classic Arduino IDE, Arduino IDE 2.x does not currently come with any libraries pre-installed. Making matters perhaps a little more confusing is that the error message when compilation fails due to a missing library is currently a bit cryptic.

But the fix is easy enough. Just follow these instructions to install the library via Library Manager:

  • From the Arduino IDE's menu, select Sketch > Include Library > Manage Libraries.... You will see the Library Manager side bar open on the left side of the window.
  • In the "Filter your search..." field, type "Servo".
  • Scroll down through the list of search results until you find "Servo by Michael Margolis, Arduino".
  • When you hover the mouse pointer over this library entry, you will see an "Install" button appear. Click on it.
  • You will now see an "Installation in progress" dialog appear. Wait for it to close, indicating the library finished installing.

Now you should be able to compile your sketch.

@pert

Question: how did you know that OP was using IDE 2.x ? Posted output looked strange to me but that was about it.

I recognized the style of error message. I was heavily involved in the testing of Arduino IDE 2.x before the public release and have also been doing a lot of support work since then so I am very familiar with all its quirks.

I submitted a bug report about the poor user and support experience that results from the change in the error message format:

There is also ongoing discussion among the team responsible for the IDE on the subject of the bundled libraries.

Thanks @pert

For me it just looked strange :wink: Glad you recognised it.

Thank you very much for the input it is much appreciated, I downloaded the library but the error still remains for some reason:

Using board 'uno' from platform in folder: C:\Users\Dean\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3
Using core 'arduino' from platform in folder: C:\Users\Dean\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3
Detecting libraries used...
"C:\Users\Dean\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-
Alternatives for Servo.h: [Servo@1.1.7]
ResolveLibrary(Servo.h)
-> candidates: [Servo@1.1.7]
"C:\Users\Dean\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/ "C:\Users\Dean\Documents\Arduino\libraries\Servo\src\megaavr\Servo.cpp" -o nul
"C:\Users\Dean\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-stw -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdataemp\arduino-sketch-1C4369200C494E02E137224A20F13BD7\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Users\Dean\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\Dean\AppData\Local\Temp\arduino-sketch-1C4369200C494E02E137224A20F13BD7\preproc\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\Users\Dean\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\Dean\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\cores\arduino" "-IC:\Users\Dean\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\variants\standard" "-IC:\Users\Dean\Documents\Arduino\libraries\Servo\src" "C:\Users\Dean\AppData\Local\Temp\arduino-sketch-1C4369200C494E02E137224A20F13BD7\sketch\sketch_mar29b.ino.cpp" -o "C:\Users\Dean\AppData\Local\Temp\arduino-sketch-1C4369200C494E02E137224A20F13BD7\sketch\sketch_mar29b.ino.cpp.o"
c:\Users\Dean\Documents\Arduino\sketch_mar29b\sketch_mar29b.ino:118:1: error: expected declaration before '}' token
}
^
Using library Servo at version 1.1.7 in folder: C:\Users\Dean\Documents\Arduino\libraries\Servo
Compilation error: Error: 2 UNKNOWN: exit status 1

Looks like another error to me. Mismatch between { and } in your code.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.