LCD I2C undefined error?(SOLVED)

Error message:

Arduino: 1.8.19 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\umarh\AppData\Local\Temp\cc5RPcmt.ltrans0.ltrans.o: In function `global constructors keyed to 65535_0_sketch_dec18a.ino.cpp.o.1753':

<artificial>:(.text.startup+0xe): undefined reference to `LiquidCrystal_I2C::LiquidCrystal_I2C(unsigned char, unsigned char, unsigned char, unsigned char)'

C:\Users\umarh\AppData\Local\Temp\cc5RPcmt.ltrans0.ltrans.o: In function `setup':

C:\Users\umarh\OneDrive\Documents\Arduino\sketch_dec18a/sketch_dec18a.ino:10: undefined reference to `LiquidCrystal_I2C::begin()'

C:\Users\umarh\OneDrive\Documents\Arduino\sketch_dec18a/sketch_dec18a.ino:13: undefined reference to `LiquidCrystal_I2C::backlight()'

collect2.exe: error: ld returned 1 exit status

exit status 1

Error compiling for board Arduino Mega or Mega 2560.



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


I was so stressed about this so can you help me?
Thanks.

Welcome to the forum

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

And …. Need to see your code , use code tags !!

Have you tried the example that comes with the library for your LCD ?

I would always start here , get that running then build from there and test at each step , that way easier to find mistakes .
Do you have the correct library installed for your LCD and code ?

Here it is:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

uint8_t bell[8]  = {0x4, 0xe, 0xe, 0xe, 0x1f, 0x0, 0x4};
uint8_t note[8]  = {0x2, 0x3, 0x2, 0xe, 0x1e, 0xc, 0x0};
uint8_t clock[8] = {0x0, 0xe, 0x15, 0x17, 0x11, 0xe, 0x0};
uint8_t heart[8] = {0x0, 0xa, 0x1f, 0x1f, 0xe, 0x4, 0x0};
uint8_t duck[8]  = {0x0, 0xc, 0x1d, 0xf, 0xf, 0x6, 0x0};
uint8_t check[8] = {0x0, 0x1 ,0x3, 0x16, 0x1c, 0x8, 0x0};
uint8_t cross[8] = {0x0, 0x1b, 0xe, 0x4, 0xe, 0x1b, 0x0};
uint8_t retarrow[8] = {  0x1, 0x1, 0x5, 0x9, 0x1f, 0x8, 0x4};

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup()
{
  lcd.begin();
  lcd.backlight();

  lcd.createChar(0, bell);
  lcd.createChar(1, note);
  lcd.createChar(2, clock);
  lcd.createChar(3, heart);
  lcd.createChar(4, duck);
  lcd.createChar(5, check);
  lcd.createChar(6, cross);
  lcd.createChar(7, retarrow);
  lcd.home();

  lcd.print("Hello world...");
  lcd.setCursor(0, 1);
  lcd.print(" i ");
  lcd.write(3);
  lcd.print(" arduinos!");
  delay(5000);
  displayKeyCodes();
}

// display all keycodes
void displayKeyCodes(void) {
  uint8_t i = 0;

  while (1) {
    lcd.clear();
    lcd.print("Codes 0x");
    lcd.print(i, HEX);
    lcd.print("-0x");
    lcd.print(i + 16, HEX);
    lcd.setCursor(0, 1);

    for (int j = 0; j < 16; j++) {
      lcd.write(i + j);
    }
    i += 16;

    delay(4000);
  }
}

void loop()
{
  // Do nothing here...
}

A quick look at an example from the LiquidCrystal_I2C library on github and it shows lcd.init() rather than lcd.begin().

As suggested, start with one of the examples that came with the library and then modify it for your own needs.

Tried. Still same...

change to lcd.init(); compiles w/- complaints , whether it works is up to you to make the appropriate connections!

Unfortunately there are several libraries called LiquidCrystal_I2C, so your suggestion may or may not work, depending on which library the OP has.

To the OP, where did you find the code, or if you wrote it yourself, where did you find the reference that you are following? That might give a clue to which library is needed.

In the future, the best library for driving I2C LCDs is the hd44780 library by Bill Perry.

Damn!

I went with this library:

@Umar_Newbie_Programmer , you need to tell us where you got the LiquidCrystal_I2C library you are using.

I found the code from the YouTube. I forgot where I found the code...

Here

Without knowing exactly which library you have downloaded, you could get all sorts of suggestions from the forums that may or may not work for you.

Did you click on a link on a website to get to the library, or did you get it via the IDE Library Manager?

Double-checked the file. that's the link I got from the library

Ok, did you try any of the examples from that library? HelloWorld would be a good one to try.

Same issue (´。_。`)

Be careful if you have more than one LiquidCrystal_I2C library, you may have to delete the incorrect one before the compiler will use the other.

Verbose output on compilation might help the diagnosis

@Umar_Newbie_Programmer
In the IDE File/Preferences tick the box "Show verbose output during compilation", compile the code and post the full output here in code tags

No! I mean.... SOLVED! Thanks!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.