[SOLVED] 'first defined here' error on building ESP8266WebServer

Hi,
I get multiple ‘first defined here’ errors when trying to compile ESP8266WebServer. Already re-installed PlatformIO for Atom, did not help.

Code
#include <Arduino.h>
#include <ESP8266WebServer.h>
ESP8266WebServer webServer(80);
void setup() {}
void loop() {}

Build output
Processing nodemcuv2 (platform: espressif8266; board: nodemcuv2; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Espressif 8266 > NodeMCU 1.0 (ESP-12E Module)
HARDWARE: ESP8266 80MHz 80KB RAM (4MB Flash)
Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
LDF MODES: FINDER(chain) COMPATIBILITY(soft)

Collected 48 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ESP8266WebServer> 1.0
|   |-- <WiFi> 1.2.7
|   |   |-- <SPI> 1.0
|   |-- <ESP8266WiFi> 1.0
Linking .pioenvs/nodemcuv2/firmware.elf
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiClient.cpp.o): In function `WiFiClient::write(unsigned char)':
WiFiClient.cpp:(.text._ZN10WiFiClient5writeEh+0x0): multiple definition of `WiFiClient::write(unsigned char)'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClient5writeEh+0x0): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiClient.cpp.o): In function `WiFiClient::peek()':
WiFiClient.cpp:(.text._ZN10WiFiClient4peekEv+0x0): multiple definition of `WiFiClient::peek()'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClient4peekEv+0x4): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiClient.cpp.o): In function `WiFiClient::connected()':
WiFiClient.cpp:(.text._ZN10WiFiClient9connectedEv+0x0): multiple definition of `WiFiClient::connected()'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClient9connectedEv+0x4): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiClient.cpp.o): In function `WiFiClient::operator bool()':
WiFiClient.cpp:(.text._ZN10WiFiClientcvbEv+0x0): multiple definition of `WiFiClient::operator bool()'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClientcvbEv+0x0): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiClient.cpp.o): In function `WiFiClient::connect(char const*, unsigned short)':
WiFiClient.cpp:(.text._ZN10WiFiClient7connectEPKct+0x10): multiple definition of `WiFiClient::connect(char const*, unsigned short)'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClient7connectEPKct+0x10): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiClient.cpp.o): In function `WiFiClient::available()':
WiFiClient.cpp:(.text._ZN10WiFiClient9availableEv+0x4): multiple definition of `WiFiClient::available()'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClient9availableEv+0x4): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiClient.cpp.o): In function `WiFiClient::stop()':
WiFiClient.cpp:(.text._ZN10WiFiClient4stopEv+0x4): multiple definition of `WiFiClient::stop()'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClient4stopEv+0x10): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiClient.cpp.o): In function `WiFiClient::connect(IPAddress, unsigned short)':
WiFiClient.cpp:(.text._ZN10WiFiClient7connectE9IPAddresst+0x54): multiple definition of `WiFiClient::connect(IPAddress, unsigned short)'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClient7connectE9IPAddresst+0x28): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiClient.cpp.o): In function `WiFiClient::write(unsigned char const*, unsigned int)':
WiFiClient.cpp:(.text._ZN10WiFiClient5writeEPKhj+0xc): multiple definition of `WiFiClient::write(unsigned char const*, unsigned int)'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClient5writeEPKhj+0x8): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiClient.cpp.o): In function `WiFiClient::flush()':
WiFiClient.cpp:(.text._ZN10WiFiClient5flushEv+0xc): multiple definition of `WiFiClient::flush()'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClient5flushEv+0x0): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiClient.cpp.o): In function `WiFiClient::read()':
WiFiClient.cpp:(.text._ZN10WiFiClient4readEv+0x4): multiple definition of `WiFiClient::read()'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClient4readEv+0x4): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiClient.cpp.o): In function `WiFiClient::read(unsigned char*, unsigned int)':
WiFiClient.cpp:(.text._ZN10WiFiClient4readEPhj+0x8): multiple definition of `WiFiClient::read(unsigned char*, unsigned int)'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClient4readEPhj+0x4): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiClient.cpp.o): In function `WiFiClient::WiFiClient()':
WiFiClient.cpp:(.text._ZN10WiFiClientC2Ev+0xc): multiple definition of `WiFiClient::WiFiClient()'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClientC2Ev+0x4): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiClient.cpp.o): In function `WiFiClient::WiFiClient()':
WiFiClient.cpp:(.text._ZN10WiFiClientC2Ev+0xc): multiple definition of `WiFiClient::WiFiClient()'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClientC2Ev+0x4): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiClient.cpp.o): In function `WiFiClient::status()':
WiFiClient.cpp:(.text._ZN10WiFiClient6statusEv+0x0): multiple definition of `WiFiClient::status()'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiClient.cpp.o):WiFiClient.cpp:(.text._ZN10WiFiClient6statusEv+0x4): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiServer.cpp.o): In function `WiFiServer::write(unsigned char)':
WiFiServer.cpp:(.text._ZN10WiFiServer5writeEh+0x0): multiple definition of `WiFiServer::write(unsigned char)'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiServer.cpp.o):WiFiServer.cpp:(.text._ZN10WiFiServer5writeEh+0x0): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiServer.cpp.o): In function `WiFiServer::write(unsigned char const*, unsigned int)':
WiFiServer.cpp:(.text._ZN10WiFiServer5writeEPKhj+0x0): multiple definition of `WiFiServer::write(unsigned char const*, unsigned int)'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiServer.cpp.o):WiFiServer.cpp:(.text._ZN10WiFiServer5writeEPKhj+0x10): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiServer.cpp.o): In function `WiFiServer::WiFiServer(unsigned short)':
WiFiServer.cpp:(.text._ZN10WiFiServerC2Et+0x8): multiple definition of `WiFiServer::WiFiServer(unsigned short)'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiServer.cpp.o):WiFiServer.cpp:(.text._ZN10WiFiServerC2Et+0x4): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiServer.cpp.o): In function `WiFiServer::WiFiServer(unsigned short)':
WiFiServer.cpp:(.text._ZN10WiFiServerC2Et+0x8): multiple definition of `WiFiServer::WiFiServer(unsigned short)'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiServer.cpp.o):WiFiServer.cpp:(.text._ZN10WiFiServerC2Et+0x4): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiServer.cpp.o): In function `WiFiServer::status()':
WiFiServer.cpp:(.text._ZN10WiFiServer6statusEv+0x0): multiple definition of `WiFiServer::status()'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiServer.cpp.o):WiFiServer.cpp:(.text._ZN10WiFiServer6statusEv+0x4): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiServer.cpp.o): In function `WiFiServer::begin()':
WiFiServer.cpp:(.text._ZN10WiFiServer5beginEv+0x4): multiple definition of `WiFiServer::begin()'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiServer.cpp.o):WiFiServer.cpp:(.text._ZN10WiFiServer5beginEv+0x10): first defined here
.pioenvs/nodemcuv2/lib2bb/libESP8266WiFi.a(WiFiServer.cpp.o): In function `WiFiServer::available(unsigned char*)':
WiFiServer.cpp:(.text._ZN10WiFiServer9availableEPh+0x18): multiple definition of `WiFiServer::available(unsigned char*)'
.pioenvs/nodemcuv2/libba4/libWiFi_ID870.a(WiFiServer.cpp.o):WiFiServer.cpp:(.text._ZN10WiFiServer9availableEPh+0x20): first defined here
collect2: error: ld returned 1 exit status
*** [.pioenvs/nodemcuv2/firmware.elf] Error 1
========================== [ERROR] Took 2.41 seconds ==========================

Thanks for your help.

Can you try and add

lib_ignore = ESP8266WiFi

in your platformio.ini. If that doesn’t work try it with WiFi. Both these libraries seem to be included but they define the same thing…

2 Likes

The first did not work but using
lib_ignore = WiFi
worked perfectly fine. Thank you very much for your quick help.
Any recommendations how to fix this problem permanent?

2 Likes

Did you install the WiFi library in global storage? Or in your local lib/folder. The LDF seems to think it must be included, which is due it having the same header file name and it being present somewhere

1 Like

The WiFi library was installed in the global storage. I uninstalled it there and could remove the lib_ignore line from the platformio.ini again.
Thank you so much!

1 Like