1

It is s a bit complicated to ask such question, but what may be the reason that one time compilation passes and other fails without any changes in code? surely debugging this way is very hard (one time commenting out one part of code seems to stop this problem and later it returns even if commenting out was canceled).

I suspect it has to do with some changes in code regarding some ArduinoJson functionality

Sketch was was tested on 2 different platforms, Linux and Mac, and error occurs on both.

What troubles me is compilation inconsistentancy rather than some bugs in my code.

Error message:

/home/guy/snap/arduino/70/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sketch/inFlash_Parameters.ino.cpp.o: in function `_Z17updateTopicsFlashRN18ArduinoJson6171_9112JsonDocumentE':
/home/guy/Documents/Dropbox/Arduino/libraries/myIOT2/examples/inFlash_Parameters/myIOT_settings.h:46: undefined reference to `_ZN6myIOT223extract_JSON_from_flashEPcRN18ArduinoJson6171_9112JsonDocumentE'
/home/guy/snap/arduino/70/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: /home/guy/Documents/Dropbox/Arduino/libraries/myIOT2/examples/inFlash_Parameters/myIOT_settings.h:44: undefined reference to `_ZN6myIOT228update_vars_flash_parametersERN18ArduinoJson6171_9112JsonDocumentE'
/home/guy/snap/arduino/70/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sketch/inFlash_Parameters.ino.cpp.o: in function `_ZN18ArduinoJson6171_9110MemoryPoolC4EPcj':
/home/guy/Documents/Dropbox/Arduino/libraries/myIOT2/examples/inFlash_Parameters/myIOT_settings.h:52: undefined reference to `_ZN6myIOT223extract_JSON_from_flashEPcRN18ArduinoJson6171_9112JsonDocumentE'
/home/guy/snap/arduino/70/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sketch/inFlash_Parameters.ino.cpp.o: in function `_Z22readParameters_inFlashv':
/home/guy/Documents/Dropbox/Arduino/libraries/myIOT2/examples/inFlash_Parameters/myIOT_settings.h:52: undefined reference to `_ZN6myIOT228update_vars_flash_parametersERN18ArduinoJson6171_9112JsonDocumentE'
/home/guy/snap/arduino/70/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: /home/guy/Documents/Dropbox/Arduino/libraries/myIOT2/examples/inFlash_Parameters/myIOT_settings.h:57: undefined reference to `_ZN6myIOT223extract_JSON_from_flashEPcRN18ArduinoJson6171_9112JsonDocumentE'
/home/guy/snap/arduino/70/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: /home/guy/Documents/Dropbox/Arduino/libraries/myIOT2/examples/inFlash_Parameters/myIOT_settings.h:59: undefined reference to `_ZN6myIOT223extract_JSON_from_flashEPcRN18ArduinoJson6171_9112JsonDocumentE'
collect2: error: ld returned 1 exit status
Multiple libraries were found for "WiFiUdp.h"
 Used: /home/guy/snap/arduino/70/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/ESP8266WiFi
 Not used: /home/guy/Documents/Dropbox/Arduino/libraries/arduino_648747
 Not used: /home/guy/Documents/Dropbox/Arduino/libraries/WiFiNINA
 Not used: /snap/arduino/70/libraries/WiFi
Multiple libraries were found for "ArduinoJson.h"
 Used: /home/guy/Documents/Dropbox/Arduino/libraries/arduino_215091
 Not used: /home/guy/Documents/Dropbox/Arduino/libraries/arduino_892158
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Sharing function that are mentioned in error to make the picture clearer:

void updateTopicsFlash(JsonDocument &DOC)
{
    for (uint8_t i = 0; i < 3; i++)
    {
        sprintf(topics_gen_pub[i], DOC["pub_gen_topics"][i]);
    }
    for (uint8_t i = 0; i < 3; i++)
    {
        sprintf(topics_pub[i], DOC["pub_topics"][i]);
    }
    for (uint8_t i = 0; i < 2; i++)
    {
        sprintf(topics_sub[i], DOC["sub_topics"][i]);
    }
}


void readParameters_inFlash()
{
    StaticJsonDocument<1250> DOC;

    iot.extract_JSON_from_flash(parameterFiles[0], DOC);
    iot.update_vars_flash_parameters(DOC);
    DOC.clear();

    iot.extract_JSON_from_flash(parameterFiles[1], DOC);
    updateTopicsFlash(DOC);
    DOC.clear();

    iot.extract_JSON_from_flash(parameterFiles[2], DOC);
    DOC.clear();
}

calling 2 functions from lib:

bool myIOT2::extract_JSON_from_flash(char *filename, JsonDocument &DOC)
{
    File readFile = LITFS.open(filename, "r");
    DeserializationError error = deserializeJson(DOC, readFile);
    readFile.close();

    if (error)
    {
        return 0;
    }
    else
    {
        return 1;
    }
}
void myIOT2::update_vars_flash_parameters(JsonDocument &DOC)
{
    useWDT = DOC["useWDT"];
    useOTA = DOC["useOTA"];
    useSerial = DOC["useSerial"];
    useFlashP = DOC["useFlashP"];
    useDebug = DOC["useDebugLog"];
    debug_level = DOC["debug_level"];
    useResetKeeper = DOC["useResetKeeper"];
    useNetworkReset = DOC["useNetworkReset"];
    noNetwork_reset = DOC["noNetwork_reset"];
    useBootClockLog = DOC["useBootClockLog"];
    ignore_boot_msg = DOC["ignore_boot_msg"];
}
7
  • 2
    Copy the files out of Dropbox and try again.
    – romkey
    Jul 11 at 3:23
  • @romkey Can you explain why?
    – guyd
    Jul 11 at 3:58
  • 3
    I think @romkey is observing that in the error messages you posted each of the references to files at Dropbox locations produced an Undefined reference error. It seems logical to move those files locally and see if the error behavior becomes more consistent.
    – RowanP
    Jul 11 at 4:02
  • 2
    You're saying that you don't get the same results when you compile twice. That doesn't happen and you're confused by it. A large chunk of your files are resident on a file synchronization service, which can change your files without you being aware of what it's doing. If you want to debug this that's the obvious thing to take out of the equation.
    – romkey
    Jul 11 at 5:08
  • 1
    Not related to the problem you are facing, but I looks at the data that you are retrieving from flash, instead of using json, it would be much more easier to deal with and much more efficient to store by using a struct.
    – hcheung
    Jul 11 at 5:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.