2
  1. I'm compiling a simple sketch that reads values from an analog input and activates a buzzer on a digital input.
  2. working on an Arduino uno.
  3. the sketch compiles and runs fine on windows and arch linux using the Arduino IDE.

I recently tried to start working with Arduino-mk, I tried to compile the said sketch and got the following compiler error (analogVal is the variable holding the analogRead):

/usr/bin/avr-gcc -mmcu=atmega328p -Wl,--gc-sections -Os -o /home/niv/Gits/bin/uno/maglove/maglove.elf

~/Gits/bin/uno/maglove/maglove.ino.o ~/Gits/bin/uno/maglove/libcore.a -lc -lm 
/home/niv/Gits/bin/uno/maglove/maglove.ino.o: In function `_GLOBAL__sub_I_nothing':
maglove.ino:(.text.startup._GLOBAL__sub_I_nothing+0xc): undefined reference to `__dso_handle'
maglove.ino:(.text.startup._GLOBAL__sub_I_nothing+0xe): undefined reference to `__dso_handle'
maglove.ino:(.text.startup._GLOBAL__sub_I_nothing+0x18): undefined reference to `__cxa_atexit'
/usr/bin/avr-ld: /home/niv/Gits/bin/uno/maglove/maglove.elf: hidden symbol `__dso_handle' isn't defined
/usr/bin/avr-ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
/home/niv/Gits/Arduino-Makefile/Arduino.mk:1416: recipe for target '/home/niv/Gits/bin/uno/maglove/maglove.elf' failed
make: *** [/home/niv/Gits/bin/uno/maglove/maglove.elf] Error 1
make: Target 'all' not remade because of errors.

I am not very experienced with Arduino yet, and google has failed me in finding this error or any keyword from it in the context of Arduino uno.

thanks.

VE7JRO
2,51519 gold badges27 silver badges29 bronze badges
asked Jan 13, 2016 at 22:44
2
  • Please add the compile line. And google "__dso_handle". Commented Jan 13, 2016 at 23:21
  • @Mikael I added the compile line. anything before that is just library compilations that go smoothly Commented Jan 18, 2016 at 14:04

1 Answer 1

2

I can't say I fully understand what is going on, but it seems that if you add:

void * __dso_handle;

You may be able to eliminate one of the problems. You might try the same trick with __cxa_atexit as well.

I found the idea by searching on:

arduino __dso_handle

This is the webpage that I found that suggested the void * hack.

answered Jan 14, 2016 at 3:16
1
  • weirdly... That worked! however it seems like an ugly workaround, I would prefer to understand whats causing this error and fix it on my Linux machine since the code needs to be good to compile on windows too, and something tells me adding these declarations might break it when compiling on windows. Commented Jan 18, 2016 at 14:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.