A compile time error
Posted: Thu Jul 15, 2021 3:53 am
in udp.cpp
in udp.h
in main.cpp
I get a compile time error
Without UDP_Start - it's compiled OK.
What is wrong?
Code: Select all
#include "udp.h"
WiFiUDP udp;
uint8_t UDP_Start(char* ssid, char* pass, uint16_t loc_port)
{
uint32_t timeout = 0;
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED)
{
#if DEBUG_ENA
Serial.print('.');
#endif
delay(1);
timeout++;
if (timeout >= UDP_CONNECT_TIMEOUT)
return 0;
}
#if DEBUG_ENA
Serial.print("Connected! IP address: ");
Serial.println(WiFi.localIP());
Serial.printf("UDP server on port %d\n", loc_port);
#endif
udp.begin(loc_port);
return 1;
}
in udp.h
Code: Select all
#ifndef _UDP_H
#define _UDP_H
#include <stdint.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
void UDP_Start(char* ssid, char* pass);
#endif
in main.cpp
Code: Select all
#include "udp.h"
void setup()
{
// put your setup code here, to run once:
UDP_Start("aaa", "vvv");
}
void loop()
{
// put your main code here, to run repeatedly:
}
I get a compile time error
c:/users/evgeny/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.3-gcc10.3-9bcba0b/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: sketch\main.ino.cpp.o:(.text.setup+0x8): undefined reference to `_Z9UDP_StartPcS_'
c:/users/evgeny/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.3-gcc10.3-9bcba0b/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: sketch\main.ino.cpp.o: in function `setup':
D:\Documents\AgroSensor\arduino_8266\main/main.ino:6: undefined reference to `_Z9UDP_StartPcS_'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board LOLIN(WEMOS) D1 mini (clone).
Without UDP_Start - it's compiled OK.
What is wrong?