multiple errors for esp8266 board and adafruit library

hello i want to make small home automation project using nodemcu esp8266 with adafruit. for that i make a one code and i add all necessary library for that esp and adadfruit mqtt library but while compiling code i found multiple library error. i try different video on youtube and try to fix this error but i failed, please give me proper solution for fix this

my code
#include <ESP8266WiFi.h>
#include “Adafruit_MQTT.h”
#include “Adafruit_MQTT_Client.h”

/************************* Pin Definition *********************************/

//Relays for switching appliances
#define Relay1 D0
#define Relay2 D1
#define Relay3 D2
#define Relay4 D3
/*********************** SSID and Password***********************************/

#define WLAN_SSID “"
#define WLAN_PASS "

/************************* Setup *********************************/

#define AIO_SERVER “
#define AIO_SERVERPORT 1883 // use 8883 for SSL
#define AIO_KEY “AIO_KEY”

/************ Global State (you don’t need to change this!) ******************/

// Create an ESP8266 WiFiClient class to connect to the MQTT server.
WiFiClient client;
// or… use WiFiFlientSecure for SSL
//WiFiClientSecure client;

// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.

/****************************** Feeds ***************************************/

// Setup a feed called ‘onoff’ for subscribing to changes.
Adafruit_MQTT_Subscribe Light1 = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME “/feeds/relay1”);
Adafruit_MQTT_Subscribe Fan1 = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME “/feeds/relay2”);
Adafruit_MQTT_Subscribe Light2 = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME “/feeds/relay3”);
Adafruit_MQTT_Subscribe Fan2 = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME “/feeds/relay4”);

/*************************** Sketch Code ************************************/

// Bug workaround for Arduino 1.6.6, it seems to need a function declaration
// for some reason (only affects ESP8266, likely an arduino-builder bug).
void MQTT_connect();

void setup() {
pinMode(Relay1, OUTPUT);
pinMode(Relay2, OUTPUT);
pinMode(Relay3, OUTPUT);
pinMode(Relay4, OUTPUT);
Serial.println(F(“Adafruit MQTT demo”));

// Connect to WiFi access point.
Serial.println(); Serial.println();
Serial.print("Connecting to ");

while (WiFi.status() != WL_CONNECTED) {

Serial.println(“WiFi connected”);
Serial.println("IP address: "); Serial.println(WiFi.localIP());

//Setting up DHT sensor
// Setup MQTT subscription for onoff feed.

uint32_t x = 0;

void loop() {
// Ensure the connection to the MQTT server is alive (this will make the first
// connection and automatically reconnect when disconnected). See the MQTT_connect
// function definition further below.
// this is our ‘wait for incoming subscription packets’ busy subloop
// try to spend your time here

Adafruit_MQTT_Subscribe *subscription;
while ((subscription = mqtt.readSubscription(20000))) {
if (subscription == &Light1) {
Serial.print(F("Got: "));
Serial.println((char *)Light1.lastread);
int Light1_State = atoi((char *)Light1.lastread);
digitalWrite(Relay1, Light1_State);

if (subscription == &Light2) {
Serial.print(F("Got: "));
Serial.println((char *)Light2.lastread);
int Light2_State = atoi((char *)Light2.lastread);
digitalWrite(Relay2, Light2_State);
if (subscription == &Fan1) {
Serial.print(F("Got: "));
Serial.println((char *)Fan1.lastread);
int Fan1_State = atoi((char *)Fan1.lastread);
digitalWrite(Relay3, Fan1_State);
if (subscription == &Fan2) {
Serial.print(F("Got: "));
Serial.println((char *)Fan2.lastread);
int Fan2_State = atoi((char *)Fan2.lastread);
digitalWrite(Relay4, Fan2_State);


error message

Arduino: 1.8.10 (Windows 10), Board: “NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200”

c:/users/shubh/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\home_automation.ino.cpp.o: in function `setup’:

E:\Work\projects\adafruit\home automation\home_automation/home_automation.ino:64: undefined reference to `MQTT_connect()’

c:/users/shubh/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: E:\Work\projects\adafruit\home automation\home_automation/home_automation.ino:63: undefined reference to `MQTT_connect()’

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for “Adafruit_MQTT.h”
Used: C:\Users\shubh\OneDrive\Documents\Arduino\libraries\Adafruit_MQTT_Library-master
Multiple libraries were found for “ESP8266WiFi.h”
Used: C:\Users\shubh\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.



You removed part of the example code that defined the function MQTT_connect(). The original example here has this code at the end of the sketch

// Function to connect and reconnect as necessary to the MQTT server.
// Should be called in the loop function and it will take care if connecting.
void MQTT_connect() {
  int8_t ret;

  // Stop if already connected.
  if (mqtt.connected()) {

  Serial.print("Connecting to MQTT... ");

  uint8_t retries = 3;
  while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected
       Serial.println("Retrying MQTT connection in 5 seconds...");
       delay(5000);  // wait 5 seconds
       if (retries == 0) {
         // basically die and wait for WDT to reset me
         while (1);
  Serial.println("MQTT Connected!");