moononournation / Arduino_GFX

Arduino GFX developing for various color displays and various data bus interfaces
Other
760 stars 151 forks source link

undefined reference to `Arduino_GFX::setFont(unsigned char const*)' #479

Closed hajjoujti closed 3 weeks ago

hajjoujti commented 1 month ago

Hello I am having an issue when using the setFont function. I am using the Arduino Mega with a ILI9486 shield display. this is my code:

#include <U8g2lib.h>
#include <Arduino_GFX_Library.h>

Arduino_DataBus *bus = new Arduino_AVRPAR16(38, 40, 39, GFX_NOT_DEFINED, 3, 1);
Arduino_GFX *gfx = new Arduino_ILI9486(bus, 41, 3, false);

void setupDisplay() {
  if (!gfx->begin()) {
    Serial.println("gfx->begin() failed!");
  }

  gfx->setFont(u8g2_font_maniac_tr);
  gfx->print("Hello World");
}

I installed the latest U8g2lib v2.34.22. I am getting the following error when I try to verify the code:

undefined reference to `Arduino_GFX::setFont(unsigned char const*)'
collect2: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

this .ino file is part of a sketch that contains another .ino which calls the setupDisplay method in its setup(). I tried to run U8g2FontHelloWorld.ino example provided with this library and it works perfectly but when I copy the content of this example and put it in my sketch it stops working and get the same error.

moononournation commented 3 weeks ago

Since the example works perfectly, you can start from the example and modify the lines one-by-one to locate your error.