Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By john77
#91878 in udp.cpp
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?
User avatar
By JTL
#91924 I am a total beginner and I see this error. Do you already have a solution to your problem? Maybe I've the same error, also for all ESP8266:
C:\UserData\Documents\Arduino\libraries\thinger.io\src/ThingerClient.h: In member function 'virtual bool ThingerClient::read(char*, size_t)':
C:\UserData\Documents\Arduino\libraries\thinger.io\src/ThingerClient.h:128:45: error: call of overloaded 'abs(long unsigned int)' is ambiguous
128 | if(read<=0 && abs(millis()-start)>=DEFAULT_READ_TIMEOUT){
| ^
In file included from c:\users\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.3-gcc10.3-9bcba0b\xtensa-lx106-elf\include\c++\10.3.0\cstdlib:75,
from c:\users\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.3-gcc10.3-9bcba0b\xtensa-lx106-elf\include\c++\10.3.0\stdlib.h:36,
from C:\Users\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266/Arduino.h:27,
from sketch\ESP8266WebConfig.ino.cpp:1:
c:\users\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.3-gcc10.3-9bcba0b\xtensa-lx106-elf\include\stdlib.h:74:5: note: candidate: 'int abs(int)'
74 | int abs (int);
| ^~~
In file included from c:\users\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.3-gcc10.3-9bcba0b\xtensa-lx106-elf\include\c++\10.3.0\cstdlib:77,
from c:\users\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.3-gcc10.3-9bcba0b\xtensa-lx106-elf\include\c++\10.3.0\stdlib.h:36,
from C:\Users\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266/Arduino.h:27,
from sketch\ESP8266WebConfig.ino.cpp:1:
c:\users\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.3-gcc10.3-9bcba0b\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
c:\users\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.3-gcc10.3-9bcba0b\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
c:\users\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.3-gcc10.3-9bcba0b\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
c:\users\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.3-gcc10.3-9bcba0b\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
c:\users\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.3-gcc10.3-9bcba0b\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
exit status 1