TM1640 demo sketch works for ATtiny85 in IDE0022, but not newer versions


I've been trying to use the TM1638 library (from GitHub - rjbatista/tm1638-library: Automatically exported from with the ATtiny85, inspired by this instructible. I'm using the arduino-tiny cores, not the MIT ones in that instructible. What I'm finding is with any of the younger IDE versions I'm getting this error when I try to verify:

TM1638\TM16XX.cpp.o:(.rodata._ZTV6TM16XX+0x14): undefined reference to `__cxa_pure_virtual'

I've tried 1.0, 1.0.1 and 1.0.4; I've also tried the TM1638 libraries v2.0.1 (the version used in that instructible it appears) and the latest 2.1.3 but in all combinations of those that error occurs.

If I roll back to Arduino IDE 0022 it compiles though. And that's with either library version.

Binary sketch size: 4042 bytes (of a 8192 byte maximum)

I'm using the code from the instructible, but the standard 2.1.3 example for TM1640 compiles okay also.

As a fallback I'll be completing this project in Arduino IDE0022, but it would be nice not to have to go retro. Any ideas what this error is pointing to?


I means that somewhere in the program a pure virtual function is declared then an object is created without supplying a definition for that function.

If you can find a function in the library that looks like this:

virtual void someFunction(...)=0;

Change it to this:

virtual void someFunction(...) { }

That should get it to compile...whether or not it works correctly is another matter. Technically it s bug in the program.

Hi fungus

The nearest thing I've found (and the only reference to the word virtual) doesn't use the virtual keyword

#if !defined(ARDUINO) || ARDUINO < 100
// empty implementation instead of pure virtual for older Arduino IDE
void TM16XX::sendChar(byte pos, byte data, boolean dot) {}

In the header there's this

	#if defined(ARDUINO) && ARDUINO >= 100
		// pure virtual is NOT supported in older Arduino IDE
		virtual void sendChar(byte pos, byte data, boolean dot) = 0;
		virtual void sendChar(byte pos, byte data, boolean dot);

From what you're saying above, should there be a corresponding #else definition in the cpp file for IDE versions 100+ that's missing?


Technically speaking, there's a bug in the program. You've declared a function:

virtual void sendChar(byte pos, byte data, boolean dot) = 0;

But you didn't provided a definition for it in a derived class.

If you can find a function called "sendChar(...)" in a derived class which has a slightly different declaration (eg. it might have a 'char' instead of a 'byte' or something in the function parameters) then that's the bug. Modify it to match the function in the header, it will override the empty function and Bob's your auntie's life-partner.

If you can't find anything like that, the best bet is to remove the pure virtual declaration. This give you pre-1.00 behavior everywhere.

ie. In the header do this:

	virtual void sendChar(byte pos, byte data, boolean dot);

In the other file do this:

// empty implementation for *ALL* IDEs
void TM16XX::sendChar(byte pos, byte data, boolean dot) {}

Fungus you are a champion. It compiles in 1.01 etc now without an error. I've also submitted this as an issue to the library author with a link here to your explanation.

Thanks ! Geoff