PlatformIO Community

Pio project will not compile on another PC

Hi there. I am using pio in vscode for an ESP32 project. The code compiles just fine on PC1 but not on PC2. Both are windows 10 64 bit. The first hints on what is going wrong are the error message, but also the dependency graph. The graph during compilation on PC2 is insanely long AND the library versions are different.
Here a small snippet of the graph:

|   |   |-- SD_control
|   |   |   |-- FS @ 1.0
|   |   |   |-- SD(esp32) @ 1.0.5
|   |   |   |   |-- FS @ 1.0
|   |   |   |   |-- SPI @ 1.0
|   |   |   |-- SPI @ 1.0
|   |   |-- FS @ 1.0
|   |   |-- SD(esp32) @ 1.0.5
|   |   |   |-- FS @ 1.0
|   |   |   |-- SPI @ 1.0
|   |   |-- SPI @ 1.0

Although I do not have access to PC1 right now, I know that SPI was @ 2.0, same for FS and SD was also being @ 2.x.x. Although not visible in the snippet, the same goes for the wire library. The platformio.ini is identical for both:

[env:firebeetle32]
platform = espressif32
board = firebeetle32
framework = arduino
upload_port = COM5
lib_ldf_mode = chain+
build_flags = 	-I include
lib_deps = 
	256dpi/MQTT@^2.5.0
	bblanchon/ArduinoJson@^6.17.3
	paulstoffregen/Time@^1.6.1
	adafruit/Adafruit ADS1X15@^2.2.0
	adafruit/Adafruit BusIO@^1.9.3

From the PIO-Home section I can see, that the plattform version of espressif32 is 3.5.0 - I think that is the most recent one and I have them on both PCs - though I can double check later if necessary.

Finally, let’s come to the error message itself:

src/system_control.cpp: In function 'void setup()':
src/system_control.cpp:134:20: error: 'to_string' is not a member of 'std'
    RTC_timestamp = std::to_string(RTC_time).c_str();
                    ^
src/system_control.cpp:135:32: error: 'to_string' is not a member of 'std'
    data_file_path = "/data/" + std::to_string(RTC_time) + "_" + string(MAC_str) + ".txt";

What I also noticed is, that I have a task.json file on PC2, what I do not have on PC1. I cant remember where it is coming from…Here the content:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "debug",
            "type": "shell",
            "command": "",
            "args": ["g++","-g", "${relativeFile}", "-o","a.exe"]
        },
        {
            "label": "Compile and run",
            "type": "shell",
            "command": "",
            "args": [
                "g++","-g", "${relativeFile}", "-o","${fileBasenameNoExtension}.out", "&&", "clear" , "&&" , "./${fileBasenameNoExtension}.out"
            ],
            "group": {
                "kind": "build",
                "isDefault": true  
            },
            "problemMatcher": {
                "owner": "cpp",
                "fileLocation": ["relative", "${workspaceRoot}"],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        },
        
    ]
}

What I tryed:

  1. Delete .pio and .vscode folders and compiled
  2. Set C_Cpp.default.cppStandard to C++17

So I assume there is something wrong with the dependencies and lib versions - any idea how I can solve this? Is reinstallation the only way?

Well if you delete .vscode and do a Ctrl+Shift+P -> Rebuild Intellisense and the file is still there, then some other conflicting extension has regenerated it.

Usually you get that file when you click the “Run” or “Debug” button on the top right of the opened file window instead of using the proper PlatformIO build task for it.

Ok, I followed you steps and the task.json file is not there anymore.

Remains the problem with the outdated libraries and the error:

error: ‘to_string’ is not a member of ‘std’

Any idea how I get the standard libraries like wire, FS, SD and so on to be updated? I guess this also solves the problem with the quoted error.

If the firmware compiles on one computer with that code, but doesn’t on another, then that other computer may be using an outdated version of the platform (for Espressif 32) and thus compiler. The quickest way to solve it is opening a CLI and executing

pio upgrade --dev
pio pkg update -g -p espressif32

then rebuild the project.

Hey Max, updating the libraries worked. Afterwards I closed VScode and re-opened, which caused Intellisense to run for 15 mins… but it finished eventually and I could build the project. However, compiling lead to another error, which I do believe is not an error

.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_common/include/esp_err.h:115:28: error: expected ‘;’ before ‘do’
#define ESP_ERROR_CHECK(x) do {
^~
lib/NVS/src/my_nvs.cpp:211:2: note: in expansion of macro ‘ESP_ERROR_CHECK’
ESP_ERROR_CHECK(nvs_erase_all(handle));.

I checked the standard esp_err.h file and I do not believe that there is an issue:

#define ESP_ERROR_CHECK(x) do {                                         \
        esp_err_t err_rc_ = (x);                                        \
        if (unlikely(err_rc_ != ESP_OK)) {                              \
            _esp_error_check_failed(err_rc_, __FILE__, __LINE__,        \
                                    __ASSERT_FUNC, #x);                 \
        }                                                               \
    } while(0)
#endif

Any suggestion what I can do to get rid of this error message?

What’s this line and the surrounding ones exactly? (aka, the macro user)

Because it looks like the line before it is missing a ;.

Wow, how on earth could that happen? I mean there were two functions having the missing “;” that at the end of line before (e.g. 210 and 223). Well, thank you for that, would have taking me a lot of time to figure that out…