Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ld returned 5 exit status" on Win XP #2989

Closed
oldmaker opened this issue Apr 17, 2015 · 56 comments
Closed

"ld returned 5 exit status" on Win XP #2989

oldmaker opened this issue Apr 17, 2015 · 56 comments
Labels
Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) Component: Toolchain The tools used for compilation and uploading to Arduino boards OS: Windows Specific to the Windows version of the Arduino IDE
Milestone

Comments

@oldmaker
Copy link

Two sketches of mine (only those two), compiling fine with IDE 1.0.x, cannot compile with new IDEs (on Windows XP): after the syntax check, appears a Windows error relative to ld.exe; then compilation stops with message "collect2.exe: error: ld returned 5 exit status".

Issue context:
IDE 1.6.1 or 1.6.2 or 1.6.3
O.S. Windows XP

The same sketches, with IDE 1.6.x, on another PC with Windows 8.1, compiles OK.
The same sketches, with IDE 1.0.x, compiles OK.

I discovered a (ridiculous) work-around: adding some totally useless global variables, the two sketches compiles OK also with IDE 1.6.x on Win XP:

int y = 0;
int z = 0;
int w = 0;

The first sketch needs at least 3 additional global variables, the second at least 6.
It doesn't matter the name, the type or the values; the only requirement seems to be the number of variables added.

Similar issues on this site: #2768 and #2813

Verbose debug output of IDE 1.6.3, on Windows XP:

Loading configuration...
Initializing packages...
Preparing boards...
Starting...


Uso la libreria Wire nella cartella: C:\Programmi\Arduino\hardware\arduino\avr\libraries\Wire

C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard -IC:\Programmi\Arduino\hardware\arduino\avr\libraries\Wire C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\Demo_NHD0420CW-Ax3_I2C.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\Demo_NHD0420CW-Ax3_I2C.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard -IC:\Programmi\Arduino\hardware\arduino\avr\libraries\Wire -IC:\Programmi\Arduino\hardware\arduino\avr\libraries\Wire\utility
C:\Programmi\Arduino\hardware\arduino\avr\libraries\Wire\Wire.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\Wire\Wire.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard -IC:\Programmi\Arduino\hardware\arduino\avr\libraries\Wire -IC:\Programmi\Arduino\hardware\arduino\avr\libraries\Wire\utility C:\Programmi\Arduino\hardware\arduino\avr\libraries\Wire\utility\twi.c -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\Wire\utility\twi.c.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\hooks.c -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\hooks.c.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\WInterrupts.c -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\WInterrupts.c.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\wiring.c -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\wiring.c.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\wiring_analog.c -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\wiring_analog.c.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\wiring_digital.c -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\wiring_digital.c.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\wiring_pulse.c -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\wiring_pulse.c.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\wiring_shift.c -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\wiring_shift.c.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\abi.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\abi.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\CDC.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\CDC.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\HardwareSerial.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial0.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\HardwareSerial0.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial1.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\HardwareSerial1.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial2.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\HardwareSerial2.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial3.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\HardwareSerial3.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\HID.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\HID.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\IPAddress.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\IPAddress.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\main.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\main.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\new.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\new.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\Print.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\Print.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\Stream.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\Stream.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\Tone.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\Tone.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\USBCore.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\USBCore.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\WMath.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\WMath.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Programmi\Arduino\hardware\arduino\avr\cores\arduino -IC:\Programmi\Arduino\hardware\arduino\avr\variants\standard C:\Programmi\Arduino\hardware\arduino\avr\cores\arduino\WString.cpp -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\WString.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\hooks.c.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\WInterrupts.c.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\wiring.c.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\wiring_analog.c.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\wiring_digital.c.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\wiring_pulse.c.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\wiring_shift.c.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\abi.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\CDC.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\HardwareSerial.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\HardwareSerial0.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\HardwareSerial1.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\HardwareSerial2.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\HardwareSerial3.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\HID.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\IPAddress.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\main.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\new.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\Print.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\Stream.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\Tone.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\USBCore.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\WMath.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\WString.cpp.o
C:\Programmi\Arduino\hardware\tools\avr/bin/avr-gcc -w -Os -Wl,--gc-sections -mmcu=atmega328p -o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/Demo_NHD0420CW-Ax3_I2C.cpp.elf C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\Demo_NHD0420CW-Ax3_I2C.cpp.o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\Wire\Wire.cpp.o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp\Wire\utility\twi.c.o C:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp/core.a -LC:\DOCUME~1\Pasquale\IMPOST~1\Temp\build9152852205119054589.tmp -lm

collect2.exe: error: ld returned 5 exit status

Errore durante la compilazione

The sketch:

/*
 * Demo_NHD0420CW-Ax3_I2C.ino
 * 
 * Tutorial sketch for use of character OLED slim display family by Newhaven with Arduino Uno, using 
 * only Wire (I2C) library.  Models: NHD0420CW-Ax3, NHD0220CW-Ax3, NHD0216CW-Ax3. Controller: US2066
 * in this example, the display is connected to Arduino via I2C interface.
 *
 * Displays on the OLED alternately a 4-line message and a sequence of character "block".
 * This sketch assumes the use of a 4x20 display; if different, modify the values of the two variables 
 * ROW_N e COLUMN_N.
 * The sketch uses the minimum possible of Arduino's pins; if you intend to use also /RES line, 
 * the related instructions are already present, it's sufficient to remove the comment markers.
 *
 * The circuit:
 * OLED pin 1 (Vss)          to Arduino pin ground
 * OLED pin 2 (VDD)          to Arduino pin 5V
 * OLED pin 3 (REGVDD)       to Arduino pin 5V
 * OLED pin 4 (SA0)          to Vss ground   (to assign I2C address 0x3D, connect to VDD 5V)
 * OLED pin 5 and 6          to Vss ground
 * OLED pin 7 (SCL)          to Arduino pin A5 (SCL); 10K pull-up resistor on OLED pin
 * OLED pin 8 and 9 (SDAin,SDAout) to Arduino pin A4 (SDA); 10K pull-up resistor on OLED pin
 * OLED pin 10 to 15         to Vss ground
 * OLED pin 16 (/RES)        to Arduino pin Reset or VDD 5V (or to Arduino pin D3, to control reset by sw)
 * OLED pin 17 (BS0)         to Vss ground
 * OLED pin 18 (BS1)         to VDD 5V
 * OLED pin 19 (BS2)         to Vss ground
 * OLED pin 20 (Vss)         to Vss ground
 *
 * Original example created by Newhaven Display International Inc.
 * Modified and adapted to Arduino Uno 15 Mar 2015 by Pasquale D'Antini
 *
 * This example code is in the public domain.
 */

#include <Wire.h>

const byte ROW_N = 4;                 // Number of display rows
const byte COLUMN_N = 20;             // Number of display columns

//const byte RES = 3;                 // Arduino's pins assigned to the Reset line (optional, can be always high)

const byte slave2w = 0x3C;            // Display I2C address, in 7-bit form: 0x3C if SA0=LOW, 0x3D if SA0=HIGH

const byte NEW_LINE[4] = {0x80, 0xA0, 0xC0, 0xE0};         // DDRAM address for each line of the display
const byte TEXT[4][21] = {"1-Newhaven Display--", 
                          "2-------Test--------", 
                          "3-16/20-Characters--", 
                          "4!@#$%^&*()_+{}[]<>?"};         // Strings to be displayed

byte tx_packet[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
                                      // Packet to be transmitted (max 20 bytes)
// _______________________________________________________________________________________

void command(byte c)                  // SUBROUTINE: PREPARES THE TRANSMISSION OF A COMMAND
{
   tx_packet[0] = 0x00;               // Control Byte; C0_bit=0, D/C_bit=0 -> following Data Byte contains command
   tx_packet[1] = c;                  // Data Byte: the command to be executed by the display
   send_packet(2);                    // Transmits the two bytes
}
// _______________________________________________________________________________________

void data(byte d)                     // SUBROUTINE: PREPARES THE TRANSMISSION OF A BYTE OF DATA
{
   tx_packet[0] = 0x40;               // Control Byte; C0_bit=0, D/C_bit=1 -> following Data Byte contains data
   tx_packet[1] = d;                  // Data Byte: the character to be displayed
   send_packet(2);                    // Transmits the two bytes
}
// _______________________________________________________________________________________

void send_packet(byte x)              // SUBROUTINE: SEND TO THE DISPLAY THE x BYTES STORED IN tx_packet
{
   byte ix = 0;                       // Bytes index
  
   Wire.beginTransmission(slave2w);   // Begin the transmission via I2C to the display with the given address
   for(ix=0; ix<x; ix++)              // One byte at a time, 
   {
      Wire.write(tx_packet[ix]);      //  queue bytes for transmission
   }
   Wire.endTransmission();            // Transmits the bytes that were queued 
}
// _______________________________________________________________________________________

void output(void)                     // SUBROUTINE: DISPLAYS THE FOUR STRINGS, THEN THE SAME IN REVERSE ORDER
{
   byte r = 0;                        // Row index
   byte c = 0;                        // Column index

   command(0x01);                     // Clears display (and cursor home)
   delay(5);                          // Waits 5 ms (after a clear display, a minimum pause of 1-2 ms is required)
   
   for (r=0; r<ROW_N; r++)            // One row at a time,
   {
      command(NEW_LINE[r]);           //  moves the cursor to the first column of that line
      for (c=0; c<COLUMN_N; c++)      // One character at a time, 
      {
         data(TEXT[r][c]);            //  displays the correspondig string
      }
   }

   delay(2000);                       // Waits 2 sec (only for visual effect purpose)
   
   for (r=0; r<ROW_N; r++)            // One row at a time,
   {
      command(NEW_LINE[r]);           //  moves the cursor to the first column of that line
      for (c=0; c<COLUMN_N; c++)      // One character at a time, 
      {
         data(TEXT[3-r][c]);          //  displays the correspondig string (in reverse order)
      }
   }
}
// _______________________________________________________________________________________

void blocks(void)                     // SUBROUTINE: FILLS THE ENTIRE DISPLAY WITH THE CHARACTER "BLOCK"
{
   byte r = 0;                        // Row index
   byte c = 0;                        // Column index

   command(0x01);                     // Clear display (and cursor home)
   delay(5);                          // Waits 5 ms (after a clear display, a minimum pause of 1-2 ms is required)

   for (r=0; r<ROW_N; r++)            // One row at a time,
   {
      command(NEW_LINE[r]);           //  moves the cursor to the first column of that line
      for (c=0; c<COLUMN_N; c++)      // One character at a time, 
      {
         data(0xDB);                  //  displays the character 0xDB (block)
         delay(100);                  // Waits 100 ms (only for visual effect purpose)
      }
      delay(1000);                    // Waits 1 sec (only for visual effect purpose)
   }
}
// _______________________________________________________________________________________

void setup(void)                      // INITIAL SETUP
{
//   pinMode(RES, OUTPUT);            // Initializes Arduino pin for the Reset line (optional)
//   digitalWrite(RES, HIGH);         // Sets HIGH the Reset line of the display (optional, can be always high)
   delayMicroseconds(200);            // Waits 200 us for stabilization purpose
   Wire.begin();      // Initiate the Wire library and join the I2C bus as a master
   delay(10);         // Waits 10 ms for stabilization purpose
   command(0x2A);     // Function set: extended command set (RE=1), CGRAM blink disable, normal display (def. val.)
   command(0x71);     // Function selection A:
   data(0x5C);        //  enable internal Vdd regulator at 5V I/O mode (def. value) (0x00 for disable, 2.8V I/O)
   command(0x28);     // Function set: fundamental command set (RE=0) (exit from extended command set)
   command(0x08);     // Display ON/OFF control: display off, cursor off, blink off (default values)
   command(0x2A);     // Function set: extended command set (RE=1), CGRAM blink disable, normal display (def. val.)
   command(0x79);     // OLED characterization: OLED command set enabled (SD=1)
   command(0xD5);     // Set display clock divide ratio/oscillator frequency:
   command(0x70);     //  divide ratio=1, frequency=7 (default values)
   command(0x78);     // OLED characterization: OLED command set disabled (SD=0) (exit from OLED command set)
   command(0x09);     // Extended function set (RE=1): 5-dot font, B/W inverting disabled (def. val.), 3/4 lines
                      //  0x08 for 2 lines ?
   command(0x06);     // Entry Mode set - COM/SEG direction: COM0->COM31, SEG99->SEG0 (BDC=1, BDS=0)
   command(0x72);     // Function selection B:
   data(0x0A);        //  ROM/CGRAM selection: ROM C, CGROM=250, CGRAM=6 (ROM=10, OPR=10)
   command(0x2A);     // Function set: extended command set (RE=1), CGRAM blink disable, normal display (def. val.)
   command(0x79);     // OLED characterization: OLED command set enabled (SD=1)
   command(0xDA);     // Set SEG pins hardware configuration:
   command(0x10);     //  alternative odd/even SEG pin, disable SEG left/right remap (default values)
   command(0xDC);     // Function selection C:
   command(0x00);     //  internal VSL, GPIO input disable
   command(0x81);     // Set contrast control:
   command(0x7F);     //  contrast=127 (default value)
   command(0xD9);     // Set phase length:
   command(0xF1);     //  phase2=15, phase1=1 (default: 0x78)
   command(0xDB);     // set VCOMH deselect level:
   command(0x40);     //  VCOMH deselect level=1 x Vcc (default: 0x20=0,77 x Vcc)
   command(0x78);     // OLED characterization: OLED command set disabled (SD=0) (exit from OLED command set)
   command(0x28);     // Function set: fundamental command set (RE=0) (exit from extended command set)
   command(0x01);     // Clear display
   delay(5);          // Waits 5 ms (after a clear display, a minimum pause of 1-2 ms is required)
   command(0x80);     // Set DDRAM address 0x00 in address counter (cursor home) (default value)
   command(0x0C);     // Display ON/OFF control: display ON, cursor off, blink off
   delay(300);        // Waits 300 ms for stabilization purpose after display on
}
// _______________________________________________________________________________________

void loop(void)                       // MAIN PROGRAM
{  
      output();                       // Execute subroutine "output"
      delay(2000);                    // Waits 2 sec (only for visual effect purpose)
      blocks();                       // Execute subroutine "blocks"
      delay(2000);                    // Waits 2 sec (only for visual effect purpose)
}

Windows crash messages:
screenshot1
screenshot2
screenshot3

@Coding-Badly
Copy link

Do you have Cygwin installed?

@Coding-Badly
Copy link

Have you tried updating the Microsoft C Run Time?

@oldmaker
Copy link
Author

  1. No, I don't use Cygwin.

  2. My system is up-to-date (as for XP); I see that is installed Microsoft Visual C++ 2010 x86 Redistributable ver. 10.0.40219; checking on Microsoft site and on Windows Update, it seems to be the last version.

I also tried disabling every possible software, without success.
It's very strange that adding some useless variables the problem disappears ....
Reading the posts on Arduino forum, I see this issue is quite common.

@oldmaker
Copy link
Author

User f41_ardu discovered another workaround for this issue: replace original file ld.exe with the file of the same name copied from the previous IDE 1.0.6.
For details see this thread on Arduino forum: http://forum.arduino.cc/index.php?topic=316146.0

@ffissore ffissore added the Component: Toolchain The tools used for compilation and uploading to Arduino boards label Apr 30, 2015
@ffissore ffissore added the OS: Windows Specific to the Windows version of the Arduino IDE label May 8, 2015
@ffissore ffissore self-assigned this Jul 1, 2015
@positron96
Copy link

I confirm this on 1.6.5.
Problem appears regardless of program size, even the most simple programs fail to compile.

Had to downgrade to 1.6.0, seems no problem (but library is missing several useful functions, e.g EEPROM.update).

@fabelec95
Copy link

I could suggest to create a Temp directory on C drive and then change TMP and TEMP system variable definition to C:\Temp.

Linkers are generally sensitive on paths content, so it is recommanded to set simpler and shorter system paths, specially on older operating systems.

1.6.5 do not fails any more on linking after this change on Windows XP.

@positron96
Copy link

Is the issue with ld known already? What exactly does error 5 mean?

@fabelec95
Copy link

I suggest this solution because it solves the problem on my side for my Arduino projects and those of my friends under Windows XP.
For true explanation, Arduino team have to investigate around linker error messages.

@positron96
Copy link

Thank you! I will try this when I encounter this bug again

@NicoHood
Copy link
Contributor

Are you living in china or why the hell are you using XP?
I guess they wont fix XP issues if they dont affect any other (supported) windows.

@positron96
Copy link

It's an educational facility that does not have resources to upgrade a dozens of computers to be able to run win7. It happens.

@positron96
Copy link

Actually, did anyone post this bug upstream? It seems to be a gcc/mingw/avr-gcc bug (sorry, don't know what project is directly related)

@cmaglie
Copy link
Member

cmaglie commented Oct 21, 2015

Googling for "ld returned 5 exit status" it seems that Arduino is not the only one that is suffering this problem. BTW I only found people complaining about the bug but nobody actually investigated the issue.

If someone has some insight about the real cause of the bug it would be really helpful.

@positron96
Copy link

If anyone can read a procmon dump here, I can provide one.
Also, changing $TEMP to something without spaces (D:\Temp) did not help me. Still getting the same error.

@positron96
Copy link

I've peeked in the ld sources and did not find any exit(5) or anything like error code 5. In Windows, however, error code 5 usually means "Access denied" and stack analysis seems to support it. When ld starts to crash, a ntoskrnl.exe!KiTrap0E is fired which in turn calls ntoskrnl.exe!MmAccessFault. Googling it shows that it is called when Page Fault error occurs. This is the most I can squeeze out of procmon dump.

@73-de-LZ
Copy link

The nasty error code 5 beat me today, find a cure by adding Serial.prinln(); at the end of void loop(). Nasty error - nasty solution, but i could not leave the things that way, so I spent few hours in investigation of forum. Test the old version of ld.exe from IDE 1.05, OK, work, but didn't like it, then added some global variables, also work fine, but this is not a solution, it is just a nasty trick. Then i try to do what fabelec95 said in the comment here and it work just fine.

  1. Make short name directory without spaces in C:, for example C:/TEMP,
  2. From the Arduino IDE 1.6.6 open "File"=>"Prefernces" and hit the link to the file "preferences.txt", close the IDE as it is written "(edit only when Arduino is not running)", so exit from all opened scetches and close Arduino IDE.
  3. Open the file preferences.txt and add at the first row this line :
    build.path=C:\TEMP
  4. Save it and start Arduino again.
    Good luck!

@rva1945
Copy link

rva1945 commented Feb 9, 2016

This is really weird. My sketch didnt' compile because of this sentence:

velocidadTren = velocidadTren-int(velocidadMaxima/aceleracionPasos);

all of them integer variables and <> zero.

I tried everything, from creating a float variable to store the calculation, to adding spaces between the variables and operators, to no avail.

But yes, there is a fix, weird too: I added this one in the declarations section:

char myvar ='hello';

and, believe or not, it fixed it! Now it compiles. I truly hope the Arduino boys are reading this.

@mralexgray
Copy link

this really hasn't been fixed yet? sad.

@cmaglie
Copy link
Member

cmaglie commented Apr 4, 2016

this really hasn't been fixed yet? sad.

@mralexgray are you affected by this bug?

The cause of this bug is still unknown and I'm still unable to reproduce it on my (two) Windows XP boxes. All the analysis made until now makes me think about some memory corruption that happens inside "ld" and under some very particular conditions (that vary from PC to PC).
There are various workarounds discovered by users, just to name few of them:

  • adding "fake" global variables
  • changing the lenght of the strings in progmem
  • even renaming the windows temp folder!

also there isn't a "common" workaround that works for everyone. What works for one user may not work for another. Moreover these are... well... workarounds and they don't give any clue on where the real bug is.

So unless someone takes the time to dig into the "ld" source and debug it, I guess that this issue will last for a long time...

@cmaglie cmaglie added the Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) label Apr 6, 2016
@walthays
Copy link

walthays commented Apr 7, 2016

I run a classroom lab with 33 Windows XP computers and do a month long Arduino unit. This year was a disaster as nearly every computer ran into this problem. I worked around it each time by adding code (a useless for loop, a String variable that does nothing, a double variable that does nothing, etc.) I am attaching two files which fail to compile on 1.6.5 and 1.6.7. The good news is that they did compile on the "nightly build" from two days ago (1.6.9 s/t). I never had problems in previous years (I update the Arduino software in August before school starts on the image I use to clone all the PCs.) It would be great if this problem could be fixed. My plan if there is no fix is to downgrade to a much older version of the IDE. I'm sorry I don't know the version that last worked perfectly, but it would be whatever version was the released version mid-August 2014. (I renamed both uploaded files to .txt but they are .ino sketches.)

compileError2.txt
compileError1.txt

@RDiazPR
Copy link

RDiazPR commented Apr 11, 2016

Adding six variables worked for me. (XP, IDE 1.6.7) . I'm ok with this strange workaround for this strange bug...

Thanks @oldmaker !

@mastrolinux
Copy link
Contributor

@walthays do you want to became an Arduino Create Editor betatester? We are interested in supporting legacy systems and we can probably help you running the latest Arduino Editor in your lab. Please contact me at webmaster at arduino.cc

@GoForSmoke
Copy link

Following 73-de-LZ commented on Nov 27, 2015 I did this and it works.
Why I think it works is simple. Somewhere the long pathnames overfilled a line buffer that now is not.
Maybe Murphy will prove me wrong but for now I can proceed.

  1. Make short name directory without spaces in C:, for example C:/TEMP,
  2. From the Arduino IDE 1.6.6 open "File"=>"Prefernces" and hit the link to the file "preferences.txt", close the IDE as it is written "(edit only when Arduino is not running)", so exit from all opened scetches and close Arduino IDE.
  3. Open the file preferences.txt and add at the first row this line :
    build.path=C:\TEMP
  4. Save it and start Arduino again.

@HiTechHiTouch
Copy link

HiTechHiTouch commented Sep 9, 2016

OK, I got a failure, source, and full dumps all zipped up. It's BIG -- 125 MB.

What's the best way to pass this to some developer who will review it and pass it to GCC?

Here's a .png screen print of some Windgb output. I'm not a windows internals person, but I suspect this is a bad pointer from uninitialized data (0xf0f0f0f0f).

windbg anaylsis

BTW, if the gnucc people could provide symbols....

This was referenced Sep 9, 2016
@HiTechHiTouch
Copy link

HiTechHiTouch commented Sep 9, 2016

I may be overthinking this and getting too subtle, but I wonder if there's some case where XP doesn't provide a clean page, but the GCC compiler expects one. C requires static "uninitialized" data to be zero.

The program does a malloc (or such) and windows provides a new page, which 99.99% of the time is clean. But there might not be a contractual obligation in this matter, so very occasionally an old page is reused and isn't zeroed out.

In particular, there are many heap manager variations in windows, and it might actually be the heap manager which is expected (by C malloc et. al.) to clear newly provided memory. But some combination of heap parameters/heap provider and GCC runtime malloc are not compatible, so C doesn't always get zeroed out memory.

What brings this to mind is that by enabling heap debugging in Gflags, I may have caused heap memory to initialize things to 0xf0f0f0f0 instead of zero, which is the source of the pointer exception I trapped above.

In other words, the dump isn't for our real problem.
processexplorer gflags

EDIT: Or maybe it is. The question is, is a static variable/class being manipulated? If it's in the heap, my first guess would be that the variable is dynamic.

@HiTechHiTouch
Copy link

Getting close!

First, running under the debugger always causes memory to be initialized with various patterns. I suspect this will be a catastrophic collision with GCC's assumption that memory allocated from the system is always zeroed out, thus automatically full-filling the C requirement that "uninitialized" means zero.

This is going to make debugging in a windows environment almost impossible. I wonder if the GCC run-time people have never done serious work under windows.

Second, good news! I've gotten an exception where memory contains 0xfeeefeee, which is the value the heap manager places in storage after the heap is freed.

Bad news: the failing program is now \liblto_plugin-0.dll, a LD.exe plug-in.

I'm afraid this is going to be a matter of rebuilding the AVR tool chain (i.e. Gcc/G++) on my system.

Why can't I find any support from the Arduino IDE people?

Here's the Windgb output:

Microsoft (R) Windows Debugger Version 6.12.0002.633 X86
Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: "c:/documents and settings/jared/local settings/application data/arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe" "-plugin" "c:/documents and settings/jared/local settings/application data/arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/bin/../libexec/gcc/avr/4.9.2/liblto_plugin-0.dll" "-plugin-opt=c:/documents and settings/jared/local settings/application data/arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/bin/../libexec/gcc/avr/4.9.2/lto-wrapper.exe" "-plugin-opt=-fresolution=C:\TMP\ccV2Ta9A.res" "-plugin-opt=-pass-through=-lgcc" "-plugin-opt=-pass-through=-lm" "-plugin-opt=-pass-through=-lc" "-plugin-opt=-pass-through=-latmega32u4" "-mavr5" "-Tdata" "0x800100" "-o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp/Ammeter.ino.elf" "c:/documents and settings/jared/local settings/application data/arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/bin/../lib/gcc/avr/4.9.2/../../../../avr/lib/avr5/crtatmega32u4.o" "-LC:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp" "-Lc:/documents and settings/jared/local settings/application data/arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/bin/../lib/gcc/avr/4.9.2/avr5" "-Lc:/documents and settings/jared/local settings/application data/arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/bin/../lib/gcc/avr/4.9.2/../../../../avr/lib/avr5" "-Lc:/documents and settings/jared/local settings/application data/arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/bin/../lib/gcc/avr/4.9.2" "-Lc:/documents and settings/jared/local settings/application data/arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/bin/../lib/gcc" "-Lc:/documents and settings/jared/local settings/application data/arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/bin/../lib/gcc/avr/4.9.2/../../../../avr/lib" "--gc-sections" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\sketch\Ammeter.ino.cpp.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\Pins_Jared\I2Cscan.c.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\NewliquidCrystal\FastIO.cpp.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\NewliquidCrystal\I2CIO.cpp.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\NewliquidCrystal\LCD.cpp.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\NewliquidCrystal\LiquidCrystal.cpp.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\NewliquidCrystal\LiquidCrystal_I2C.cpp.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\NewliquidCrystal\LiquidCrystal_I2C_ByVac.cpp.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\NewliquidCrystal\LiquidCrystal_SI2C.cpp.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\NewliquidCrystal\LiquidCrystal_SR.cpp.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\NewliquidCrystal\LiquidCrystal_SR1W.cpp.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\NewliquidCrystal\LiquidCrystal_SR2W.cpp.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\NewliquidCrystal\LiquidCrystal_SR3W.cpp.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\NewliquidCrystal\SI2CIO.cpp.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\Wire\Wire.cpp.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\Wire\utility\twi.c.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp\libraries\SDL_Arduino_INA3221\SDL_Arduino_INA3221.cpp.o" "C:\TMP\build692751f7cbd22bc67458fdfc887a2b9c.tmp/core\core.a" "-lm" "--start-group" "-lgcc" "-lm" "-lc" "-latmega32u4" "--end-group"

Symbol search path is: srv_c:\symbols_https://msdl.microsoft.com/download/symbols

Executable search path is:
ModLoad: 00400000 0051b000 image00400000
ModLoad: 7c900000 7c9b4000 ntdll.dll
LDR: Stack trace database size is 100 Mb
ModLoad: 7c800000 7c8f7000 C:\WINDOWS\System32\kernel32.dll
ModLoad: 77c10000 77c68000 C:\WINDOWS\System32\msvcrt.dll
ModLoad: 7e410000 7e4a1000 C:\WINDOWS\System32\USER32.dll
ModLoad: 77f10000 77f5a000 C:\WINDOWS\System32\GDI32.dll
(418.ea0): Break instruction exception - code 80000003 (first chance)
eax=00141eb4 ebx=7ffdf000 ecx=00000007 edx=00000080 esi=00141f48 edi=00141eb4
eip=7c90120e esp=0111fb20 ebp=0111fc94 iopl=0 nv up ei pl nz na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000202
ntdll!DbgBreakPoint:
7c90120e cc int 3
0:000> g
ModLoad: 76390000 763ad000 C:\WINDOWS\system32\IMM32.DLL
ModLoad: 77dd0000 77e6b000 C:\WINDOWS\System32\ADVAPI32.dll
ModLoad: 77e70000 77f03000 C:\WINDOWS\System32\RPCRT4.dll
ModLoad: 77fe0000 77ff1000 C:\WINDOWS\System32\Secur32.dll
ModLoad: 76bf0000 76bfb000 C:\WINDOWS\system32\psapi.dll
ModLoad: 63480000 6349e000 c:\documents and settings\jared\local settings\application data\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2\libexec\gcc\avr\4.9.2\liblto_plugin-0.dll

(418.ea0): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=feeefeee ebx=feeefeee ecx=77c2c2e3 edx=00230608 esi=00516ec0 edi=004c4e9a
eip=004526e8 esp=0111fe60 ebp=0111ff78 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010206
*** ERROR: Module load completed but symbols could not be loaded for image00400000
image00400000+0x526e8:
004526e8 8b4308 mov eax,dword ptr [ebx+8] ds:0023:feeefef6=????????

@positron96
Copy link

Hey there! Good work debugging this stuff.
I guess Arduino IDE devs give no support because this issue is not related to Arduino IDE at all. The best place for this issue to be explored is probably AVR-GCC project. I have no idea where its page is, probably it's a GCC subproject.

@facchinm
Copy link
Member

Hi @HiTechHiTouch ,
thanks for diving deeply into this problem. We've been testing internally on a bunch of XP machines until we were able to reproduce the bug consistently. If you could test the "updated" binary, you can find it here (http://downloads.arduino.cc/tools/avr-gcc-4.9.2-atmel3.5.3-arduino3-i686-mingw32.zip). This build patches ld to avoid taking a risky path (read, containing SSE instructions) and adds debug flags, which are stripped by -s but seems to help initializing the memory safely.
If you could test this build it would be really great. Thanks again for the effort!

@cmaglie
Copy link
Member

cmaglie commented Sep 12, 2016

I'm afraid this is going to be a matter of rebuilding the AVR tool chain (i.e. Gcc/G++) on my system.

the build scripts used to create the toolchain are here:

https://github.com/arduino/toolchain-avr

launching package-avr-gcc.bash from a mingw32 shell should do the work (beware: it could take several hours to complete...).

@HiTechHiTouch
Copy link

@facchinm will work on it. You seem to be ahead of where I think I will end up going.

@positron96 I'm thinking the Arduino GUI people are just copying this stuff from Atmel. I look at C:\Program Files\Arduino\hardware\tools\avr\builtin_tools_versions.txt and see
arduino.avrdude=6.0.1-arduino5
arduino.avr-gcc=4.8.1-arduino5
and the when I push a "-v" at the collect invocation, I see 4.9.2. Then I swap over to Atmel Studio and see their current tool chain is also 4.9.2. Hmmmm.

@HiTechHiTouch
Copy link

@cmaglie Yes, MinGW seems to be the way to go. I got a precompiled 4.9.2 setup off github but haven't fired it up.

My Current problem:

mingw sets an environment variable (bash env) from windows environment, and strips off the drive letter from c:/mingw/bin in the PATH variable.

Now I cd out to another drive where I have my sources, run scripts, and (I think) bash looks for mingw/bin on my source drive, not my c: drive.

Any suggestions? Any site for mingw support, or do people just depend on stackoverflow.com ?

@HiTechHiTouch
Copy link

@facchinm Martino, please email me. HiTechHiTouch on yahoo mail.

@cmaglie
Copy link
Member

cmaglie commented Sep 12, 2016

mingw sets an environment variable (bash env) from windows environment, and strips off the drive letter from c:/mingw/bin in the PATH variable.

uhm, I never had this problem since I have only one drive C:.

I'm not really a mingw expert, but maybe it's worth trying to a have a look at the "C:\msys\1.0\etc\fstab" file? on my Windows box C:/mingw is mapped to /mingw, maybe changing this will help in your case. (see http://www.mingw.org/wiki/msys for details)

@HiTechHiTouch
Copy link

HiTechHiTouch commented Sep 13, 2016

@cmaglie After I installed cygwin, the problem "went away". I suspect stuff that should be coming out of mingw/bin may actually be coming out of cygwin/bin. cygwin is explicit about being first in PATH, and mingw said to append to the end of PATH.

I don't like running with mixed modules, i..e. GCC 4.9.1 in mingw and 5.2.0 in cygwin. But so far, no really obvious problems.

PS: Tried to send you email at arduino.cc. It bounced, so please email me (see above).

@HiTechHiTouch
Copy link

Still working, but the build process has become a real swamp of alligators.

@ghost
Copy link

ghost commented Oct 13, 2016

I had the same problem. I found that by including the "Wire" library it compiled fine.

@sppnk
Copy link

sppnk commented Nov 3, 2016

Compiling a simple code I have found 1.6.12 Arduino IDE version still have the issue. Windows 10.

Adding or removing some functions it apperas/dissapears.

@sppnk
Copy link

sppnk commented Nov 3, 2016

...and changing ld.exe with the ld.exe from 1.0.5 or 1.0.6 doesnt work, because old ld.exe's cannot read 'plugin' extra commands and exits with another error.

Should be easy to fix, as adding or removing a single line of code (a redundant function by example) can make it compile.

@jk987
Copy link

jk987 commented Dec 13, 2016

I have:
WinXP SP3 (modified in regedit to POSReady to get updates)
Arduino IDE 1.6.13
Digispark board with ATTiny85
(I also have some chineese copy of Arduino Nano)

And today I even couldn't compile empty sketch like this:

void setup() {
}
void loop() {
}

The error is the same:
collect2.exe: error: ld returned 5 exit status

Last line in log before error was:
"c:\Program Files\Arduino\portable\packages\arduino\tools\avr-gcc\4.8.1-arduino5/bin/avr-gcc" -Os -Wl,--gc-sections -mmcu=attiny85 -o "c:\tmp/tiny_lowpower.ino.elf" "c:\tmp\sketch\tiny_lowpower.ino.cpp.o" "c:\tmp\core\pins_arduino.c.o" "c:\tmp\core\core.a" "-Lc:\tmp" -lm
From this you can see that I already tried the trick with changing "build.path" in "preferences.txt" and also creating "portables" subdirectory. Both these tricks should avoid using stupid AppData directory which in my native language contains diacritics and spaces and lot of other software doesn't handle it correctly.

What helped me was to move Arduino IDE out of "c:\program files\arduino" to "c:\arduino". That's quite common trick to make older software work in Windows7 but I didn't expect that it will make new Arduino SW work in Windows XP.

@Sporotrix
Copy link

Hi, just my 5 cents of contribution. I had the same problem as everyone, Windows XP, IDE 1.6.13 and crazy compilation erros. As the error sugested something related to my board, I decided to downgrade the board specs (Tools > Board > board manager > find your board > select older version > install). I went from "Arduino AVR boards" 1.6.15 back to 1.6.2 and things started working. Didn't noticed any functionality losses or any other errors/bugs with the downgrade. Will try to go up a little to see if thigs stay working.

@sdikiy
Copy link

sdikiy commented Dec 18, 2016

+1
Windows XP, IDE 1.6.13
collect2.exe: error: ld returned 5 exit status
exit status 1
Error compiling for board Arduino Nano.

...same sketch on Win7(64), IDE 1.6.13 - All is OK!

@cmaglie
Copy link
Member

cmaglie commented Jan 18, 2017

Can someone check if the build provided here
#5863 (comment)
may solve the issue?

@Earl-deLaFere
Copy link

Hi All!

I confirm that "Update bundled tools # 5863" solves this problem for me.
Earlier, even the compilation of a very simple sketch, such as Blink, caused the error "collect2.exe: error: ld returned 5 exit status".
After installing the nightly build at 08.03.2017, the compilation of this simple sketch and 14 different ones was successful.

My test environment: Windows XP SP3, CPU AMD Athlon (tm) XP 2400+, Genuino UNO.

Because My CPU is AMD Athlon XP, I would be glad if in the next release the utility arduino-builder, and other utilities written on GO, would be compiled with the parameter GO386 = 387 disabling SSE2. Otherwise, I have to recompile arduino-builder from the source code myself.

@cmaglie
Copy link
Member

cmaglie commented Mar 30, 2017

Fixed on IDE 1.8.2 (and AVR core 1.6.18).

@cmaglie cmaglie closed this as completed Mar 30, 2017
@cmaglie cmaglie added this to the Release 1.8.2 milestone Mar 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) Component: Toolchain The tools used for compilation and uploading to Arduino boards OS: Windows Specific to the Windows version of the Arduino IDE
Projects
None yet
Development

No branches or pull requests