Errors when compiling a program using LiquidCrystal.h

Hello

when I try to compile program:

#include "LiquidCrystal.h"

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

float input_voltage = 0.0;
float temp=0.0;


void setup()
{
   Serial.begin(9600);     //  opens serial port, sets data rate to 9600 bps
   lcd.begin(16, 2);       //// set up the LCD's number of columns and rows: 
   lcd.print("DIGITAL VOLTMETER");
}
void loop()
{

//Conversion formula for voltage
   
   int analog_value = analogRead(A0);
   input_voltage = (analog_value * 5.0) / 1024.0; 

   
   if (input_voltage < 0.1) 
   {
     input_voltage=0.0;
   } 
    Serial.print("v= ");
    Serial.println(input_voltage);
    lcd.setCursor(0, 1);
    lcd.print("Voltage= ");
    lcd.print(input_voltage);
    delay(300);
}

from this tutorial onto my arduino nano every, I get following errors:
In file included from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\libraries\LiquidCrystal\src\LiquidCrystal.cpp:1:0:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\libraries\LiquidCrystal\src\LiquidCrystal.h:45:36: error: expected class-name before ‘{’ token
class LiquidCrystal : public Print {
^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\libraries\LiquidCrystal\src\LiquidCrystal.h:86:9: error: ‘Print’ has not been declared
using Print::write;
^~~~~
exit status 1

How can I fix it?

Compiles fine for me.

compiles fine for me, too.

I think that you may not have the right LiquidCrystal library or your library is corrupted. There are several by that name and they are not all alike. The one that I have installed is the one that comes with the IDE. That library can be found in the library manager, Topic, Displays.

I do not use any of the libraries named LiquidCrystal or LiquidCrystal I2C. I use the hd447980 library for all my hd44780 based LCDs. It is just a better library.

That's the bad thing about the internet anybody is free to post code and information of any quality-level.
From deepest rubbish to best quality.

If you want to test the LCD-display try the examples that are delivered with the Arduino IDE.

If you want to test the ADC throw out the LCD-library and re-code for serial output.

maybe you did something wrong with the Installationof of the Arduino IDE.

best regards Stefan

I would have thought this was fixed by now, which version of the IDE and megaAVR core are you using?

There was is a bug in Print.h in at least one the latest (1.8.6) version of the megaAVR core.

See reply #4 in this thread https://forum.arduino.cc/index.php?topic=678338.0

david_2018 gave the answer while I was writing, but I'll post it anyway:

This is a known bug in the official Arduino core library used by the Arduino megaAVR Boards platform:

It has already been fixed:

but there hasn't been a release of the Arduino megaAVR Boards since then.

The easy fix is to roll back to the previous version of the Arduino megaAVR Boards platform, which doesn't have the bug:

  • (In the Arduino IDE) Tools > Board > Boards Manager
  • Wait for the downloads to finish
  • From the list of available boards platforms, click on "Arduino megaAVR Boards".
  • From the "Select version" menu, select "1.8.5".
  • Click the "Install" button.
  • Wait for the installation of Arduino megaAVR Boards 1.8.5 to finish.
  • Click the "Close" button.

The issue should now be fixed.

You may occasionally get notifications that a newer version of the boards platform is available. If you update back to 1.8.6 again, the problem will come back. However, you should keep an eye out for the new 1.8.7 (or whatever) release, since this will have the fix and whatever other useful improvements were made. So once that comes out you should definitely update.


ALTERNATE FIX
NOTE: this is an alternate to the fix I described above. Don't do both fixes!!! Pick one or the other.

Here's a slightly more complex fix that allows you to continue to use Arduino megaAVR Boards 1.8.6:

Open the file:
C:\Users{username}\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.6\cores\arduino\api\Print.h
in a text editor.

Add the following line at the end of the file;

using namespace arduino;

Save the file.

david_2018:
I would have thought this was fixed by now

Well, technically it is fixed, but that fix isn't so much help to the users untill it's released.