Sketch with ArdunioOTA won't compile after moving libraries

Hi, grateful if anyone can point me in the right direction with this issue. I've been working on a ESP8266 project for a few days and everything has been going fine. I noticed a message advising I had two copies of a library so thought I would tidy things up and moved all my libraries to C:\Users\Peter\Documents\Arduino\libraries where most of them were already located.
Suddenly I get this error message on my Esp8266 Sketch:

'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'setHostname'

Other sketches compile OK.
I can still compile the same sketch on my laptop with IDE 1.8.13 ArduinoOTA Library 1.0.5 - no problems
But using my PC with the same IDE and Library I get the error message - SO - the sketch is fine, the IDE is fine, the Library is fine - but in moving the libraries I have created a problem.

I've tried these steps:

  1. Restored the deleted libraries to their original locations
  2. Uninstalled and re-installed the latest version of IDE
  3. Searched the net and read the post: ESP8266 OTA Example Won't Compile - #9 by CaptClaude - PlatformIO Community - but dont think it's relevant to this problem
  4. Compared the Library files on my laptop with those on my PC

Short of rebuilding the PC I'm out of ideas - any suggestions? Thanks in advance.
Full error message below:

Arduino: 1.8.13 (Windows 7), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

\\NAS_DUO\backup\Documents\Ardiuno\Sketches\Kegerator_Testing\Kegerator_Testing.ino: In function 'void setup_OTA()':

Kegerator_Testing:279:14: error: 'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'setHostname'

   ArduinoOTA.setHostname("test_keg");        //was ESP8266

              ^

Kegerator_Testing:280:14: error: 'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'setPassword'

   ArduinoOTA.setPassword("test8266");

              ^

Kegerator_Testing:281:14: error: 'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'onStart'

   ArduinoOTA.onStart([]() {

              ^

Kegerator_Testing:284:14: error: 'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'onEnd'

   ArduinoOTA.onEnd([]() {

              ^

Kegerator_Testing:287:14: error: 'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'onProgress'

   ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {

              ^

Kegerator_Testing:290:25: error: 'ota_error_t' has not been declared

   ArduinoOTA.onError([](ota_error_t error) {

                         ^

\\NAS_DUO\backup\Documents\Ardiuno\Sketches\Kegerator_Testing\Kegerator_Testing.ino: In lambda function:

Kegerator_Testing:292:18: error: 'OTA_AUTH_ERROR' was not declared in this scope

     if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");

                  ^

Kegerator_Testing:293:23: error: 'OTA_BEGIN_ERROR' was not declared in this scope

     else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");

                       ^

Kegerator_Testing:294:23: error: 'OTA_CONNECT_ERROR' was not declared in this scope

     else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");

                       ^

Kegerator_Testing:295:23: error: 'OTA_RECEIVE_ERROR' was not declared in this scope

     else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");

                       ^

Kegerator_Testing:296:23: error: 'OTA_END_ERROR' was not declared in this scope

     else if (error == OTA_END_ERROR) Serial.println("End Failed");

                       ^

\\NAS_DUO\backup\Documents\Ardiuno\Sketches\Kegerator_Testing\Kegerator_Testing.ino: In function 'void setup_OTA()':

Kegerator_Testing:297:4: error: invalid user-defined conversion from 'setup_OTA()::__lambda8' to 'void (*)(int, const char*)' [-fpermissive]

   });

    ^

\\NAS_DUO\backup\Documents\Ardiuno\Sketches\Kegerator_Testing\Kegerator_Testing.ino:290:42: note: candidate is: setup_OTA()::__lambda8::operator void (*)(int)() const <near match>

   ArduinoOTA.onError([](ota_error_t error) {

                                          ^

\\NAS_DUO\backup\Documents\Ardiuno\Sketches\Kegerator_Testing\Kegerator_Testing.ino:290:42: note:   no known conversion for implicit 'this' parameter from 'void (*)(int)' to 'void (*)(int, const char*)'

Kegerator_Testing:298:20: error: no matching function for call to 'ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>::begin()'

   ArduinoOTA.begin();

                    ^

\\NAS_DUO\backup\Documents\Ardiuno\Sketches\Kegerator_Testing\Kegerator_Testing.ino:298:20: note: candidate is:

In file included from \\NAS_DUO\backup\Documents\Ardiuno\Sketches\Kegerator_Testing\Kegerator_Testing.ino:14:0:

C:\Users\Peter\Documents\Arduino\libraries\ArduinoOTA\src/ArduinoOTA.h:87:8: note: void ArduinoOTAMdnsClass<NetServer, NetClient, NetUDP>::begin(IPAddress, const char*, const char*, OTAStorage&) [with NetServer = WiFiServer; NetClient = WiFiClient; NetUDP = WiFiUDP]

   void begin(IPAddress localIP, const char* name, const char* password, OTAStorage& storage) {

        ^

C:\Users\Peter\Documents\Arduino\libraries\ArduinoOTA\src/ArduinoOTA.h:87:8: note:   candidate expects 4 arguments, 0 provided

exit status 1

'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'setHostname'



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

Relevant Parts of Sketch:

#include <ESP8266WiFi.h>
#include <ArduinoOTA.h>
#include <PubSubClient.h>
#include <ESP8266WebServer.h>
#include <OneWire.h>
#include <DallasTemperature.h>

void setup() {

  Serial.begin(115200);         // Start the Serial communication to send messages to the computer
  Serial.println('\n');
  sensors.begin();
  setup_wifi();
  setup_OTA();
  setup_MQTT();
  setup_web_server();
  pinMode(compPin, OUTPUT);
  digitalWrite(compPin, 0);                       //  compressor Relay off to start (Low State)                            //  fan Relay off to start (High State)
  compressorOff = millis();                            //initial delay starting compressor
  readTemp();

}

void setup_OTA(){

  ArduinoOTA.setHostname("test_keg");        //was ESP8266
  ArduinoOTA.setPassword("test8266");
  ArduinoOTA.onStart([]() {
    Serial.println("Start");
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
    else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
    else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
    else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
    else if (error == OTA_END_ERROR) Serial.println("End Failed");
  });
  ArduinoOTA.begin();
  Serial.println("OTA ready");
  
}

void loop() {
  ArduinoOTA.handle();
  if (!client.connected()) {
    reconnect();
  }
  client.loop();
  server.handleClient();
  checkTheTime();
}

Please do this (stock reply, so please don't get offended by the instructions that are obvious to you):

  • (In the Arduino IDE) click File > Preferences
  • Check the box next to "Show verbose output during: > compilation
  • Click "OK"
  • Sketch > Verify/Compile
  • After the compilation fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the compilation output between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.

If the length of the output exceeds the forum's 9000 character limit, save it in a .txt file and post it here as an attachment. If you click the "Reply" button you'll see the "Attachments and other options" link that will allow you to make the attachment.

I noticed a message advising I had two copies of a library so thought I would tidy things up and moved all my libraries to C:\Users\Peter\Documents\Arduino\libraries where most of them were already located.

Which of the two libraries with the same name did you keep ?
Where were the duplicates located before you moved them ?

C:\Users\Peter\Documents\Arduino\libraries\ArduinoOTA\src/ArduinoOTA.h:87:8: note:   candidate expects 4 arguments, 0 provided

Using library ESP8266WiFi at version 1.0 in folder: C:\Users\Peter\Documents\Arduino\libraries\ESP8266WiFi 

Using library ArduinoOTA at version 1.0.5 in folder: C:\Users\Peter\Documents\Arduino\libraries\ArduinoOTA 

Using library PubSubClient at version 2.8 in folder: C:\Users\Peter\Documents\Arduino\libraries\PubSubClient 

Using library ESP8266WebServer at version 1.0 in folder: C:\Users\Peter\Documents\Arduino\libraries\ESP8266WebServer 

Using library OneWire at version 2.3.5 in folder: C:\Users\Peter\Documents\Arduino\libraries\OneWire 

Using library DallasTemperature at version 3.9.0 in folder: C:\Users\Peter\Documents\Arduino\libraries\DallasTemperature 

exit status 1

'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'setHostname'

Full Error Message in attachment.

Error Message.txt (77.2 KB)

UKHeliBob:
Which of the two libraries with the same name did you keep ?
Where were the duplicates located before you moved them ?

Hi UKHeliBob, thanks for taking time out to respond.
Your last question first:
I found libraries in these locations:
C:\Users\Peter\Documents\Arduino\libraries
C:\Users\Peter\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries
C:\Users\Peter\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0
I kept the folder in C:\Users\Peter\Documents\Arduino\libraries

which has the libraries.properties file with this data, which I'm hoping is the latest library
name=ArduinoOTA
version=1.0.5
author=Arduino,Juraj Andrassy
maintainer=Juraj Andrassy juraj.andrassy@gmail.com
sentence=Upload sketch over network to Arduino board with WiFi or Ethernet libraries
paragraph=Based on WiFi101OTA library. Uploads over Ethernet, UIPEthernet, WiFi101, WiFiNina, WiFiLink, WiFi, WiFiEspAT to SAMD, nRF5, esp8266, esp32 and to ATmega with more then 64 kB flash memory.
category=Other
url=GitHub - JAndrassy/ArduinoOTA: Arduino library to upload sketch over network to Arduino board with WiFi or Ethernet libraries
architectures=*
includes=ArduinoOTA.h
dot_a_linkage=true

Prickles:
I found libraries in these locations:
C:\Users\Peter\Documents\Arduino\libraries
C:\Users\Peter\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries
C:\Users\Peter\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0
I kept the folder in C:\Users\Peter\Documents\Arduino\libraries

You didn't mention that you also removed libraries from this folder:

C:\Users\Peter\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries

Previously, the ArduinoOTA library that would have been used is:

C:\Users\Peter\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ArduinoOTA

So when you deleted that folder, you changed the library used by your sketch. So I suspect that the problem is that the sketch was written to be used with the ArduinoOTA library bundled with the ESP8266 boards platform, rather than Juraj's library of the same name.

I'm sure Juraj's library is excellent, but just maybe not what the sketch was designed to use.

I think that your approach of moving the platform bundled libraries to your sketchbook is a bad idea. The platform bundled libraries are intended only to be accessible when compiling for a board of that platform. When you move them to your sketchbook, you make them globally available. You also will prevent the updated version of the platform bundled libraries from being used after you update to a new version of the boards platform. So my advice is to remove all those libraries from your sketchbook and then reinstall the boards platforms you modified. You can do that via Tools > Board > Boards Manager by clicking the "Remove" button and then the "Install" button on each platform. The downloaded files are cached, so it won't go through the whole download process over again, only the unzip.

Don't be afraid of that "Multiple libraries found" message. It's not an error. It's only some helpful information the Arduino IDE is providing. As long as the library you intended was picked, you can simply ignore it.

Nailed it! Thanks for your help pert, I'm very grateful for your assistance. Also for your advice on leaving multiple libraries.

You're welcome. I'm glad if I was able to be of assistance. Enjoy!
Per