Home>

The sample code was executed to use milkcocoa with esp8266, but an error occurred when compiling. It seems that an error has occurred in the code in the library, so I do not know how to deal with it. What should I do about it?

Error message
Arduino: 1.8.5 (Mac OS X), Board: "Generic ESP8266 Module, 80 MHz, Flash, nodemcu, 26 MHz, 40 MHz, QIO, 2M (1M SPIFFS), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200 "
In file included from /Users/username/Documents/Arduino/libraries/Milkcocoa_ESP8266_SDK-master/Milkcocoa.h:31:0,
                 from /Users/username/Documents/Arduino/libraries/Milkcocoa_ESP8266_SDK-master/examples/milkcocoa_esp8266/milkcocoa_esp8266.ino:2:
/Users/username/Documents/Arduino/libraries/Milkcocoa_ESP8266_SDK-master/include/aJson/aJson.h:92:6: error: conflicting return type specified for 'virtual int aJsonStream :: flush ()'
  int flush ();
      ^
In file included from /Users/username/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/Stream.h:26:0,
                 from /Users/username/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/HardwareSerial.h:31,
                 from /Users/username/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/Arduino.h:261,
                 from sketch/milkcocoa_esp8266.ino.cpp: 1:
/Users/username/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/Print.h:93:22: error: overriding 'virtual void Print :: flush ()'
         virtual void flush () {/ * Empty implementation for backward compatibility * /}
                      ^
exit status 1
An error occurred when compiling for the board Generic ESP8266 Module.
From "Preferences" in the "File" menu
When "Show more detailed information: Compile" is enabled
More detailed information is displayed.
Applicable source code
// Create an ESP8266 WiFiClient class to connect to the MQTT server.
WiFiClient client;
const char MQTT_SERVER [] PROGMEM = MILKCOCOA_APP_ID ".mlkcca.com";
const char MQTT_CLIENTID [] PROGMEM = __TIME__ MILKCOCOA_APP_ID;
Milkcocoa milkcocoa = Milkcocoa (&client, MQTT_SERVER, MILKCOCOA_SERVERPORT, MILKCOCOA_APP_ID, MQTT_CLIENTID);
void onpush (DataElement * elem) {
  Serial.println ("onpush");
  Serial.println (elem->getInt ("v"));
};
void setupWiFi () {
  Serial.println ();Serial.println ();
  Serial.print ("Connecting to");
  Serial.println (WLAN_SSID);
  WiFi.begin (WLAN_SSID, WLAN_PASS);
  while (WiFi.status ()! = WL_CONNECTED) {
    delay (500);
    Serial.print (".");
  }
  Serial.println ();
  Serial.println ("WiFi connected");
  Serial.println ("IP address:");
  Serial.println (WiFi.localIP ());
}
void setup () {
  Serial.begin (115200);
  delay (10);
  Serial.println (F ("Milkcocoa SDK demo"));
  setupWiFi ();
  Serial.println (milkcocoa.on (MILKCOCOA_DATASTORE, "push", onpush));
};
void loop () {
  milkcocoa.loop ();
  DataElement elem = DataElement ();
  elem.setValue ("v", 1);
  milkcocoa.push (MILKCOCOA_DATASTORE,&elem);
  delay (7000);
};

The sample code was executed. (SSID, milkcocoa's appID, etc. have been rewritten to those I use.)

  • Answer # 1

    What is the board manager version?
    The same error has occurred in the past depending on the version.
    The reference StackOverflow page is
    esp8266 by ESP8266 community Version 2.4.0 causes compilation error
    is.

    Do you still get an error when trying with a different version of the board manager?
    Do you need to check?