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

undefined reference to `__cxa_guard_acquire' - was: Template issues?! #1498

Closed
tuxedo0801 opened this issue Jan 25, 2016 · 14 comments
Closed

Comments

@tuxedo0801
Copy link
Contributor

Hi there,

I'm not a real C++ expert, but trying to port a arduino library to esp8266/Arduino... (working with Arduino IDE 1.6.6 on Debian Linux 8 arm64 and 2.1.0-rc2 via boardmanager)

I thought doing a #ifdef here and there would do it. But now I'm struggling with this issue:

When compiling, I get the following error:

...../KnxDevice.cpp:236:106: error: duplicate explicit instantiation of 'e_KnxDeviceStatus KnxDevice::read(byte, T&) [with T = unsigned char; byte = unsigned char]' [-fpermissive]
 template e_KnxDeviceStatus KnxDevice::read <unsigned char>(byte objectIndex, unsigned char& returnedValue);
                                                                                                          ^
...../KnxDevice.cpp:283:98: error: duplicate explicit instantiation of 'e_KnxDeviceStatus KnxDevice::write(byte, T) [with T = unsigned char; byte = unsigned char]' [-fpermissive]
 template e_KnxDeviceStatus KnxDevice::write <unsigned char>(byte objectIndex, unsigned char value);

And that's the corresponding KnxDevice.cpp (line 235-243):

template e_KnxDeviceStatus KnxDevice::read <boolean>(byte objectIndex, boolean& returnedValue);
template e_KnxDeviceStatus KnxDevice::read <unsigned char>(byte objectIndex, unsigned char& returnedValue);
template e_KnxDeviceStatus KnxDevice::read <char>(byte objectIndex, char& returnedValue);
template e_KnxDeviceStatus KnxDevice::read <unsigned int>(byte objectIndex, unsigned int& returnedValue);
template e_KnxDeviceStatus KnxDevice::read <int>(byte objectIndex, int& returnedValue);
template e_KnxDeviceStatus KnxDevice::read <unsigned long>(byte objectIndex, unsigned long& returnedValue);
template e_KnxDeviceStatus KnxDevice::read <long>(byte objectIndex, long& returnedValue);
template e_KnxDeviceStatus KnxDevice::read <float>(byte objectIndex, float& returnedValue);
template e_KnxDeviceStatus KnxDevice::read <double>(byte objectIndex, double& returnedValue);

and the related snippet from the header file:

    template <typename T>  e_KnxDeviceStatus read(byte objectIndex, T& returnedValue);

Of course it's a kind of duplicate, but with a different type flavor.
With arduino board the code compiles fine.

Any hints on this?

@tuxedo0801
Copy link
Contributor Author

Is the "template" feature missing with the compiler the esp8266/Arduino is using?

@tuxedo0801
Copy link
Contributor Author

Come on... Anyone out there working with templates?

@igrr
Copy link
Member

igrr commented Jan 26, 2016

A bunch of ESP8266 libraries use templates, like ESP8266WebServer and EEPROM, so I don't think there is a constraint from the compiler end. Perhaps you could point to the complete code you are trying to port?

@Links2004
Copy link
Collaborator

template are working on the esp8266
example:

template<typename T>
T &get(int address, T &t) {
if (address < 0 || address + sizeof(T) > _size)
return t;
memcpy((uint8_t*) &t, _data + address, sizeof(T));
return t;
}
template<typename T>
const T &put(int address, const T &t) {
if (address < 0 || address + sizeof(T) > _size)
return t;
memcpy(_data + address, (const uint8_t*) &t, sizeof(T));
_dirty = true;
return t;
}

@tuxedo0801
Copy link
Contributor Author

Thanks for feedback.

The code I'm trying to port:

https://github.com/KONNEKTING/KonnektingDeviceLibrary

--> https://github.com/KONNEKTING/KonnektingDeviceLibrary/blob/master/KnxDevice.cpp#L239

As I said: I'm not a real c++ expert. Would be great if someone could give me a hint on what's wrong?! (even if this is not a topic for this issue-tracker)

thanks a lot,

Alex

@tuxedo0801
Copy link
Contributor Author

Had a bit time to further investigate...

If I testwise remove the templates which use "unsigned char", I no longer get the duplicate-error.

But:

> /tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/sketch/KnxDevice_PushButton_with_Programming.ino.cpp.o:(.text._Z9knxEventsh+0x10): undefined reference to `e_KnxDeviceStatus KnxDevice::write<bool>(unsigned char, bool)'
> /tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/sketch/KnxDevice_PushButton_with_Programming.ino.cpp.o: In function `knxEvents(unsigned char)':
> /media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary/examples/KnxDevice_PushButton_with_Programming/KnxDevice_PushButton_with_Programming.ino:35: undefined reference to `e_KnxDeviceStatus KnxDevice::write<bool>(unsigned char, bool)'
> /tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/libraries/KonnektingDeviceLibrary/KnxTpUart.cpp.o:(.text._ZN9KnxTpUart6RXTaskEv+0x14): undefined reference to `__cxa_guard_acquire'
> /tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/libraries/KonnektingDeviceLibrary/KnxTpUart.cpp.o:(.text._ZN9KnxTpUart6RXTaskEv+0x18): undefined reference to `__cxa_guard_release'
> /tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/libraries/KonnektingDeviceLibrary/KnxTpUart.cpp.o:(.text._ZN9KnxTpUart6RXTaskEv+0x37): undefined reference to `__cxa_guard_acquire'
> /tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/libraries/KonnektingDeviceLibrary/KnxTpUart.cpp.o: In function `KnxTpUart::RXTask()':
> /media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary/KnxTpUart.cpp:515: undefined reference to `__cxa_guard_release'
> collect2: error: ld returned 1 exit status

This tells me: the template with the unsigned char type is missing ?!

So, it has to do - somehow - with the unsigned char template.

Any ideas?

best regards,
Alex

@Links2004
Copy link
Collaborator

undefined reference to __cxa_guard_release is the problem here.
the problem is tracked here: #500

@tuxedo0801
Copy link
Contributor Author

Of course it's undefined, I commented out the template with the "unsigned char" type, but another code part still uses it....

All i wanted to show is: my templates are working, except the unsigned char type templates...

The actual problem is, when I use the template with type "unsigned char", I get duplicate erors... See above.

@tuxedo0801
Copy link
Contributor Author

Steps to reproduce:

You will get error:

/home/foobar/arduino-1.6.7/arduino-builder -dump-prefs -logger=machine -hardware "/home/foobar/arduino-1.6.7/hardware" -hardware "/home/foobar/.arduino15/packages" -tools "/home/foobar/arduino-1.6.7/tools-builder" -tools "/home/foobar/arduino-1.6.7/hardware/tools/avr" -tools "/home/foobar/.arduino15/packages" -built-in-libraries "/home/foobar/arduino-1.6.7/libraries" -libraries "/media/bigdisk/Programming/Arduino/Sketchbook/libraries" -fqbn=esp8266:esp8266:generic:UploadTool=esptool,CpuFrequency=80,FlashFreq=40,FlashMode=qio,UploadSpeed=115200,FlashSize=512K64,ResetMethod=ck,Debug=Disabled,DebugLevel=None____ -ide-version=10607 -build-path "/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary/examples/KnxDevice_PushButton_with_Programming/KnxDevice_PushButton_with_Programming.ino"
/home/foobar/arduino-1.6.7/arduino-builder -compile -logger=machine -hardware "/home/foobar/arduino-1.6.7/hardware" -hardware "/home/foobar/.arduino15/packages" -tools "/home/foobar/arduino-1.6.7/tools-builder" -tools "/home/foobar/arduino-1.6.7/hardware/tools/avr" -tools "/home/foobar/.arduino15/packages" -built-in-libraries "/home/foobar/arduino-1.6.7/libraries" -libraries "/media/bigdisk/Programming/Arduino/Sketchbook/libraries" -fqbn=esp8266:esp8266:generic:UploadTool=esptool,CpuFrequency=80,FlashFreq=40,FlashMode=qio,UploadSpeed=115200,FlashSize=512K64,ResetMethod=ck,Debug=Disabled,DebugLevel=None____ -ide-version=10607 -build-path "/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary/examples/KnxDevice_PushButton_with_Programming/KnxDevice_PushButton_with_Programming.ino"
"/home/foobar/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/tools/sdk/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DARDUINO=10607 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266  -DESP8266       "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/cores/esp8266" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/variants/generic" "/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/sketch/KnxDevice_PushButton_with_Programming.ino.cpp" -o "/dev/null"
"/home/foobar/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/tools/sdk/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DARDUINO=10607 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266  -DESP8266       "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/cores/esp8266" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/variants/generic" "-I/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary" "/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/sketch/KnxDevice_PushButton_with_Programming.ino.cpp" -o "/dev/null"
"/home/foobar/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/tools/sdk/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DARDUINO=10607 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266  -DESP8266       "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/cores/esp8266" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/variants/generic" "-I/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/EEPROM" "/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/sketch/KnxDevice_PushButton_with_Programming.ino.cpp" -o "/dev/null"
"/home/foobar/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/tools/sdk/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DARDUINO=10607 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266  -DESP8266       "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/cores/esp8266" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/variants/generic" "-I/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/EEPROM" "/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary/KnxComObject.cpp" -o "/dev/null"
"/home/foobar/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/tools/sdk/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DARDUINO=10607 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266  -DESP8266       "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/cores/esp8266" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/variants/generic" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/EEPROM" "-I/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary" "/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary/KnxDevice.cpp" -o "/dev/null"
"/home/foobar/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/tools/sdk/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DARDUINO=10607 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266  -DESP8266       "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/cores/esp8266" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/variants/generic" "-I/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/EEPROM" "/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary/KnxTelegram.cpp" -o "/dev/null"
"/home/foobar/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/tools/sdk/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DARDUINO=10607 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266  -DESP8266       "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/cores/esp8266" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/variants/generic" "-I/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/EEPROM" "/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary/KnxTools.cpp" -o "/dev/null"
"/home/foobar/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/tools/sdk/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DARDUINO=10607 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266  -DESP8266       "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/cores/esp8266" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/variants/generic" "-I/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/EEPROM" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/SoftwareSerial" "/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary/KnxTools.cpp" -o "/dev/null"
"/home/foobar/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/tools/sdk/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DARDUINO=10607 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266  -DESP8266       "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/cores/esp8266" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/variants/generic" "-I/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/EEPROM" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/SoftwareSerial" "/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary/KnxTpUart.cpp" -o "/dev/null"
"/home/foobar/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/tools/sdk/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DARDUINO=10607 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266  -DESP8266       "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/cores/esp8266" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/variants/generic" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/EEPROM" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/SoftwareSerial" "-I/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary" "/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/EEPROM/EEPROM.cpp" -o "/dev/null"
"/home/foobar/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/tools/sdk/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DARDUINO=10607 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266  -DESP8266       "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/cores/esp8266" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/variants/generic" "-I/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/EEPROM" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/SoftwareSerial" "/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/sketch/KnxDevice_PushButton_with_Programming.ino.cpp" -o "/dev/null"
"/home/foobar/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/tools/sdk/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DARDUINO=10607 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266  -DESP8266       "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/cores/esp8266" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/variants/generic" "-I/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/EEPROM" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/SoftwareSerial" "/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/SoftwareSerial/SoftwareSerial.cpp" -o "/dev/null"
"/home/foobar/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/tools/sdk/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DARDUINO=10607 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266  -DESP8266       "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/cores/esp8266" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/variants/generic" "-I/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/EEPROM" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/SoftwareSerial" "/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/sketch/KnxDevice_PushButton_with_Programming.ino.cpp" -o "/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/preproc/ctags_target_for_gcc_minus_e.cpp"
"/home/foobar/arduino-1.6.7/tools-builder/ctags/5.8-arduino5/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/preproc/ctags_target_for_gcc_minus_e.cpp"
"/home/foobar/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/tools/sdk/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections -DF_CPU=80000000L   -DARDUINO=10607 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266  -DESP8266 "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/cores/esp8266" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/variants/generic" "-I/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/EEPROM" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/SoftwareSerial" "/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/sketch/KnxDevice_PushButton_with_Programming.ino.cpp" -o "/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/sketch/KnxDevice_PushButton_with_Programming.ino.cpp.o"
Zuvor kompilierte Datei wird verwendet: /tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/libraries/KonnektingDeviceLibrary/KnxComObject.cpp.o
"/home/foobar/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/tools/sdk/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections -DF_CPU=80000000L   -DARDUINO=10607 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266  -DESP8266 "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/cores/esp8266" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/variants/generic" "-I/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/EEPROM" "-I/home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/SoftwareSerial" "/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary/KnxDevice.cpp" -o "/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/libraries/KonnektingDeviceLibrary/KnxDevice.cpp.o"
/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary/KnxDevice.cpp:252:106: error: duplicate explicit instantiation of 'e_KnxDeviceStatus KnxDevice::read(byte, T&) [with T = unsigned char; byte = unsigned char]' [-fpermissive]
 template e_KnxDeviceStatus KnxDevice::read <unsigned char>(byte objectIndex, unsigned char& returnedValue);
                                                                                                          ^
/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary/KnxDevice.cpp:298:98: error: duplicate explicit instantiation of 'e_KnxDeviceStatus KnxDevice::write(byte, T) [with T = unsigned char; byte = unsigned char]' [-fpermissive]
 template e_KnxDeviceStatus KnxDevice::write <unsigned char>(byte objectIndex, unsigned char value);
                                                                                                  ^
Bibliothek KonnektingDeviceLibrary im Ordner: /media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary (legacy) wird verwendet
Bibliothek EEPROM in Version 1.0 im Ordner: /home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/EEPROM  wird verwendet
Bibliothek SoftwareSerial in Version 1.0 im Ordner: /home/foobar/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc2/libraries/SoftwareSerial  wird verwendet
exit status 1
Fehler beim Kompilieren.

@tuxedo0801
Copy link
Contributor Author

@Links2004
Your're right, must have to do with the linked issue. Will check this...

@tuxedo0801
Copy link
Contributor Author

If I understood the linked issue correctly, one should not declare static variables and initialize them by a methode call at once.

Problem is: I don't find such a "declare static and initialize by method call" constellation in my code.

My code makes use of a static class instance to access the API of the library.

I try to explain with some code snippets:

From the header (of the library I try to port to ESP8266):

The static instance of the main class of the library:
https://github.com/KONNEKTING/KonnektingDeviceLibrary/blob/master/KnxDevice.h#L134

public:
    static KnxDevice Knx; // unique KnxDevice instance (singleton design pattern)

The constructor itself is private, singleton-pattern... just use the static instance.
https://github.com/KONNEKTING/KonnektingDeviceLibrary/blob/master/KnxDevice.h#L128

  // Constructor, Destructor
    KnxDevice();  // private constructor (singleton design pattern)
    ~KnxDevice() {}  // private destructor (singleton design pattern)
    KnxDevice (const KnxDevice&); // private copy constructor (singleton design pattern) 

The user can then use the singleton to access the library:
https://github.com/KONNEKTING/KonnektingDeviceLibrary/blob/master/examples/KnxDevice_PushButton_with_Programming/KnxDevice_PushButton_with_Programming.ino#L32

Knx.write(2, true );

The above shown "write" command is one of the templated-methods:
https://github.com/KONNEKTING/KonnektingDeviceLibrary/blob/master/KnxDevice.cpp#L297

template e_KnxDeviceStatus KnxDevice::write <boolean>(byte objectIndex, boolean value);
template e_KnxDeviceStatus KnxDevice::write <unsigned char>(byte objectIndex, unsigned char value);
template e_KnxDeviceStatus KnxDevice::write <char>(byte objectIndex, char value);
template e_KnxDeviceStatus KnxDevice::write <unsigned int>(byte objectIndex, unsigned int value);
template e_KnxDeviceStatus KnxDevice::write <int>(byte objectIndex, int value);
template e_KnxDeviceStatus KnxDevice::write <unsigned long>(byte objectIndex, unsigned long value);
template e_KnxDeviceStatus KnxDevice::write <long>(byte objectIndex, long value);
template e_KnxDeviceStatus KnxDevice::write <float>(byte objectIndex, float value);
template e_KnxDeviceStatus KnxDevice::write <double>(byte objectIndex, double value);

So, I don't see the same case explained in issue #500, but according to the latest build error (fixed some other smaller things, the duplicate is now gone), it's somehow related to this issue:

/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/sketch/KnxDevice_PushButton_with_Programming.ino.cpp.o:(.text._Z9knxEventsh+0x10): undefined reference to `e_KnxDeviceStatus KnxDevice::write<bool>(unsigned char, bool)'
/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/sketch/KnxDevice_PushButton_with_Programming.ino.cpp.o: In function `knxEvents(unsigned char)':
/tmp/arduino_bb4fcaf6d0d53941d44b612db42cc988/KnxDevice_PushButton_with_Programming.ino:35: undefined reference to `e_KnxDeviceStatus KnxDevice::write<bool>(unsigned char, bool)'
/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/libraries/KonnektingDeviceLibrary/KnxTpUart.cpp.o:(.text._ZN9KnxTpUart6RXTaskEv+0x14): undefined reference to `__cxa_guard_acquire'
/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/libraries/KonnektingDeviceLibrary/KnxTpUart.cpp.o:(.text._ZN9KnxTpUart6RXTaskEv+0x18): undefined reference to `__cxa_guard_release'
/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/libraries/KonnektingDeviceLibrary/KnxTpUart.cpp.o:(.text._ZN9KnxTpUart6RXTaskEv+0x37): undefined reference to `__cxa_guard_acquire'
/tmp/buildbb4fcaf6d0d53941d44b612db42cc988.tmp/libraries/KonnektingDeviceLibrary/KnxTpUart.cpp.o: In function `KnxTpUart::RXTask()':
/media/bigdisk/Programming/Arduino/Sketchbook/libraries/KonnektingDeviceLibrary/KnxTpUart.cpp:515: undefined reference to `__cxa_guard_release'
collect2: error: ld returned 1 exit status

So I'm still lost :-(

p.s. the duplicate error mentioned at the beginning is gone, if I add "-fpermissive" (which I found at the end of the error message as a hint) to the gcc call. Required me to modify platform.txt a bit:

compiler.cpreprocessor.flags=-fpermissive -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I{compiler.sdk.path}/include"

@tuxedo0801 tuxedo0801 changed the title Template issues?! undefined reference to `__cxa_guard_acquire' - was: Template issues?! Jan 30, 2016
@tuxedo0801
Copy link
Contributor Author

Both issues fixed:

the guard issue is fixed by a PR and the duplicate error is fixed by changing one template from type "boolean" to "bool".

@Merdeka
Copy link

Merdeka commented Feb 23, 2016

tuxedo0801 can you explain how you fixed this?

I replaced all the boolean to bool in KnxDevice.cpp and KnxDevice.h.
That resolved the template issue.

But i don't really understand the "the guard issue is fixed by a PR" part.

@tuxedo0801
Copy link
Contributor Author

The actual issue was already discussed here: #500

And @iggr fixed this about 18 days ago: c62858f

But there is no release that contains this bugfix. I guess it will be available soon:

https://github.com/esp8266/Arduino/releases

Look forward for release 2.1.0-RC3 or final 2.1.0 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants