queezythegreat / arduino-cmake

Arduino CMake Build system
645 stars 216 forks source link

Linking fails when arduino SoftwareSerial is used #91

Closed efernandesng closed 10 years ago

efernandesng commented 10 years ago

Hi,

When I try make some project that uses Arduino SoftwareSerial lib, I get always same error.

My last test, was with SoftwareSerial Example.

CMakeLists.txt

generate_arduino_example(teste
                         LIBRARY SoftwareSerial
                         EXAMPLE SoftwareSerialExample
                         BOARD  uno
                         PORT /dev/ttyACM0)

Output

/usr/share/arduino/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino:51: undefined reference to `__dso_handle'
/usr/share/arduino/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino:53: undefined reference to `__dso_handle'
/usr/share/arduino/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino:53: undefined reference to `__cxa_atexit'
/usr/bin/avr-ld: bcalor.elf: hidden symbol `__dso_handle' isn't defined
/usr/bin/avr-ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
efernandesng commented 10 years ago

Resolved!!

Added below code to file

#include SoftwareSerial.h
extern "C"
{
void *__dso_handle = NULL;
}
extern "C"
{
void *__cxa_atexit = NULL;
}