Collect2.exe: error: ld returned 1 exit status for ESP8266

Can anybody help me solve this problem, I am sorry if I am making mistakes here, I am a beginner.

It’s difficult to see from the image, however, it looks like you are using the Arduino framework, but setup() and loop() are missing?

If you need the framework, you need both. If you don’t want the framework, and have your own setup and loop code in main(), delete the framework = arduino line from platformio.ini.

That should resolve things, but, if anything you coded uses the Arduino Language, or pulls in a library which does, you’ll have further problems to sort out!

FYI: You can copy the error messages, or code, from the log/output and pasted into your posting betewwen triple (or more) backticks:

```
Like this...
```

Cheers,
Norm.

Your Thermostat.ino file in examples/ won’t be compiled, since the example folders are all ignored. You need to pull it into the src/ folder. Hence the ‘undefined refernce to setup and loop’ errors.

Thanks all,
Yes, Norman, the framework is Arduino and Thermostat.ino has a loop and setup.
Max, I have moved thermostat.ino into /src folder the older problem replaced by a newer one \NtpClientLib_ESP.cpp , which is a creation of the owner of the code.
what do you think?

I have included the link to original source in Github.

Apparently this needs an older LWIP version. Although the code does differentiate between LWIP v1 and v2, for v2 this exact function seems to have been removed in the newest-used LWIP v2.

A solution would be to use the same platform version as when the project was created, around Feb 2018 would correspond to platform = espressif8266@2.3.3 per this).

If you want to build it with the current version, you can still use the older SDK and older LWIP versions and variants per docs.

Using this platformio.ini

[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
; this board does not have defaulte SCL and SDA pins for I2C
; and gives compilations errors. --> simply use nodemcu.
;board = espectro
framework = arduino
build_flags = -D PIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH 
lib_deps =
     adafruit/Adafruit BusIO @ ^1.7.2
     adafruit/Adafruit BMP085 Library @ ^1.2.0
     paulstoffregen/Time @ ^1.6

lets me compile the project.

Linking .pio\build\nodemcuv2\firmware.elf
Building .pio\build\nodemcuv2\firmware.bin
Retrieving maximum program size .pio\build\nodemcuv2\firmware.elf
Checking size .pio\build\nodemcuv2\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [====      ]  38.0% (used 31156 bytes from 81920 bytes)
Flash: [====      ]  38.3% (used 399780 bytes from 1044464 bytes)
Creating BIN file ".pio\build\nodemcuv2\firmware.bin" using "C:\Users\Max\.platformio\packages\framework-arduinoespressif8266\bootloaders\eboot\eboot.elf" and ".pio\build\nodemcuv2\firmware.elf"
======================= [SUCCESS] Took 12.56 seconds =======================