Compile error Adafruit_mfGFX

Hi,

I’m experimenting with the Photon and an I2C OLED display. It works beautifully with the ssd1306-128x64-spi.ino example.
Now I want to change the font using the Adafruit_mfGFX libray. Unfortunately I can’t get it to compile.
I get the following error:

/src/Adafruit_mfGFX.cpp: In member function 'void Adafruit_GFX::drawChar(int16_t, int16_t, unsigned char, uint16_t, uint16_t, uint8_t)':
/src/Adafruit_mfGFX.cpp:486:7: warning: 'line' may be used uninitialized in this function [-Wmaybe-uninitialized]
       if (line & 0x80) {

I get the error when using the community library and when I use github and add them as .h and .cpp.

Can someone help me on my way to get this working?
Thanks,
Jacco

This is only a warning that doesn’t prevent your build.

Try to post the error message instead :wink:

1 Like

The entire error message is:

    /src/Adafruit_mfGFX.cpp: In member function 'void Adafruit_GFX::drawChar(int16_t, int16_t, unsigned char, uint16_t, uint16_t, uint8_t)':
/src/Adafruit_mfGFX.cpp:486:7: warning: 'line' may be used uninitialized in this function [-Wmaybe-uninitialized]
       if (line & 0x80) {
       ^
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::invertDisplay(bool)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:420: multiple definition of `Adafruit_GFX::drawLine(short, short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:230: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawRoundRect(short, short, short, short, short, unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:462: multiple definition of `Adafruit_GFX::drawRect(short, short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:272: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawFastVLine(short, short, short, unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:470: multiple definition of `Adafruit_GFX::drawFastVLine(short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:280: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawFastHLine(short, short, short, unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:476: multiple definition of `Adafruit_GFX::drawFastHLine(short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:286: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::fillRect(short, short, short, short, unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:482: multiple definition of `Adafruit_GFX::fillRect(short, short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:292: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::fillScreen(unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:489: multiple definition of `Adafruit_GFX::fillScreen(unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:299: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::invertDisplay(bool)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:727: multiple definition of `Adafruit_GFX::invertDisplay(bool)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:570: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::Adafruit_GFX(short, short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:297: multiple definition of `Adafruit_GFX::Adafruit_GFX(short, short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:48: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::Adafruit_GFX(short, short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:297: multiple definition of `Adafruit_GFX::Adafruit_GFX(short, short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:48: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawCircle(short, short, short, unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:311: multiple definition of `Adafruit_GFX::drawCircle(short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:121: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawCircleHelper(short, short, short, unsigned char, unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:345: multiple definition of `Adafruit_GFX::drawCircleHelper(short, short, short, unsigned char, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:155: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::fillCircleHelper(short, short, short, unsigned char, short, unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:388: multiple definition of `Adafruit_GFX::fillCircleHelper(short, short, short, unsigned char, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:198: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::fillCircle(short, short, short, unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:381: multiple definition of `Adafruit_GFX::fillCircle(short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:191: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawRoundRect(short, short, short, short, short, unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:495: multiple definition of `Adafruit_GFX::drawRoundRect(short, short, short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:305: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::fillRoundRect(short, short, short, short, short, unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:510: multiple definition of `Adafruit_GFX::fillRoundRect(short, short, short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:320: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawTriangle(short, short, short, short, short, short, unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:522: multiple definition of `Adafruit_GFX::drawTriangle(short, short, short, short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:332: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::fillTriangle(short, short, short, short, short, short, unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:531: multiple definition of `Adafruit_GFX::fillTriangle(short, short, short, short, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:341: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawBitmap(short, short, unsigned char const*, short, short, unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:608: multiple definition of `Adafruit_GFX::drawBitmap(short, short, unsigned char const*, short, short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:418: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::drawChar(short, short, unsigned char, unsigned short, unsigned short, unsigned char)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:641: multiple definition of `Adafruit_GFX::drawChar(short, short, unsigned char, unsigned short, unsigned short, unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:462: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::write(unsigned char)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:621: multiple definition of `Adafruit_GFX::write(unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:431: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::setCursor(short, short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:675: multiple definition of `Adafruit_GFX::setCursor(short, short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:507: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::setTextSize(unsigned char)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:680: multiple definition of `Adafruit_GFX::setTextSize(unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:512: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::setTextColor(unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:686: multiple definition of `Adafruit_GFX::setTextColor(unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:518: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::setTextColor(unsigned short, unsigned short)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:690: multiple definition of `Adafruit_GFX::setTextColor(unsigned short, unsigned short)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:522: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::setTextWrap(bool)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:695: multiple definition of `Adafruit_GFX::setTextWrap(bool)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:527: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::getRotation()':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:700: multiple definition of `Adafruit_GFX::getRotation()'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:532: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::setRotation(unsigned char)':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:703: multiple definition of `Adafruit_GFX::setRotation(unsigned char)'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:535: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::width()':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:721: multiple definition of `Adafruit_GFX::width()'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:564: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o): In function `Adafruit_GFX::height()':
lib/Adafruit_SSD1306/src/Adafruit_GFX.cpp:725: multiple definition of `Adafruit_GFX::height()'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):/src/Adafruit_mfGFX.cpp:568: first defined here
../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o):(.rodata._ZTV12Adafruit_GFX+0x0): multiple definition of `vtable for Adafruit_GFX'
../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o):(.rodata._ZTV12Adafruit_GFX+0x0): first defined here
/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld: Warning: size of symbol `_ZTV12Adafruit_GFX' changed from 60 in ../../../build/target/user/platform-6/libuser.a(Adafruit_mfGFX.o) to 56 in ../../../build/target/user/platform-6/libuser.a(Adafruit_GFX.o)
collect2: error: ld returned 1 exit status
make: *** [1bcce493c16398f6ad459aa291ec8dc9d3a1e57b3a4597d82513d4c7b512.elf] Error 1

You seem to have both Adafruit_GFX and Adafruit_mfGFX library imported in your project.

Adafruit_SSD1306 brings its own copy of Adafruit_GFX (which is a bad habbit) so you cannot have Adafruit_mfGFX imorted too.

Hi,

Thanks, the moment I pasted the error message I noticed why this error is generated.

But, I only included Adafruit_SSD1306.h and Adafruit_mfGFX as community library.
It looks if Adafruit_SSD1306.h includes Adafruit_GFX. How do I prevent this with a community library?

When I include the code as .cpp and .h, replace Adafruit_GFX with Adafruit_mfGFX than the App compile’s without an error.

Thanks again ScruffR

Hence I said

Ah…right. I’ll read better next time :grinning:
Thanks

Well now it compiles but how do I use it? I’m definitely a beginner :wink:
When I use setfont I get error:

/src/Adafruit_mfGFX.cpp: In member function 'void Adafruit_GFX::drawChar(int16_t, int16_t, unsigned char, uint16_t, uint16_t, uint8_t)':
/src/Adafruit_mfGFX.cpp:486:7: warning: 'line' may be used uninitialized in this function [-Wmaybe-uninitialized]
       if (line & 0x80) {
       ^
/src/ssd1306_128x64_spi.cpp: In function 'void setup()':
/src/ssd1306_128x64_spi.cpp:84:11: error: 'class Adafruit_SSD1306' has no member named 'setfont'
 
           ^

make[1]: *** [../build/target/user/platform-6src/ssd1306_128x64_spi.o] Error 1
make: *** [user] Error 2

Hmmm…I really should read better :unamused: It is setFont and not setfont!

2 Likes