SOLVED: undefined reference to `WiFiUDP

**** Solved ******

I figured out that it did not like paths in the includes, so I had to delete Arduinos wifi lib so to force it to use the esp32 wifi lib, which I took out pathname.

*** OP:
OK, I got around that error. But now I'm getting a heap of errors:

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o:(.literal.startup._GLOBAL__sub_I_ipD+0x14): undefined reference to `WiFiUDP::WiFiUDP()'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o:(.literal._Z9wifiSetupv+0x4): undefined reference to `WiFi'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o:(.literal._Z9wifiSetupv+0x2c): undefined reference to `WiFiSTAClass::config(IPAddress, IPAddress, IPAddress, IPAddress, IPAddress)'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o:(.literal._Z9wifiSetupv+0x30): undefined reference to `WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool)'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o:(.literal._Z9wifiSetupv+0x34): undefined reference to `WiFiSTAClass::status()'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o:(.literal._Z9wifiSetupv+0x38): undefined reference to `WiFiSTAClass::localIP()'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o:(.literal._Z9wifiSetupv+0x3c): undefined reference to `WiFiUDP::begin(unsigned short)'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o:(.literal._Z7sendUdpPc+0xc): undefined reference to `WiFiUDP::beginPacket(IPAddress, unsigned short)'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o:(.literal._Z7sendUdpPc+0x10): undefined reference to `WiFiUDP::write(unsigned char)'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o:(.literal._Z7sendUdpPc+0x14): undefined reference to `WiFiUDP::endPacket()'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o:(.literal._Z7UdpReadv+0x8): undefined reference to `WiFiUDP::parsePacket()'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o:(.literal._Z7UdpReadv+0xc): undefined reference to `WiFiUDP::read(char*, unsigned int)'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o:(.literal.exit._GLOBAL__sub_D_ipD+0x0): undefined reference to `WiFiUDP::~WiFiUDP()'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o: In function `_GLOBAL__sub_I_ipD':

C:\Users\matt\Documents\Arduino\new54/new54.ino:629: undefined reference to `WiFiUDP::WiFiUDP()'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o: In function `wifiSetup()':

C:\Users\matt\Documents\Arduino\new54/new54.ino:147: undefined reference to `WiFiSTAClass::config(IPAddress, IPAddress, IPAddress, IPAddress, IPAddress)'

C:\Users\matt\Documents\Arduino\new54/new54.ino:149: undefined reference to `WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool)'

C:\Users\matt\Documents\Arduino\new54/new54.ino:149: undefined reference to `WiFiSTAClass::status()'

Multiple libraries were found for "Wire.h"
 Used: C:\Users\matt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\libraries\Wire
C:\Users\matt\Documents\Arduino\new54/new54.ino:158: undefined reference to `WiFiSTAClass::localIP()'

 Not used: C:\Program Files (x86)\Arduino\libraries\Wire
C:\Users\matt\Documents\Arduino\new54/new54.ino:159: undefined reference to `WiFiUDP::begin(unsigned short)'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o: In function `IPAddress::IPAddress(IPAddress const&)':

C:\Users\matt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\cores\esp32/IPAddress.h:29: undefined reference to `WiFiUDP::beginPacket(IPAddress, unsigned short)'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o: In function `sendUdp(char*)':

C:\Users\matt\Documents\Arduino\new54/new54.ino:919: undefined reference to `WiFiUDP::write(unsigned char)'

C:\Users\matt\Documents\Arduino\new54/new54.ino:917: undefined reference to `WiFiUDP::endPacket()'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o: In function `UdpRead()':

C:\Users\matt\Documents\Arduino\new54/new54.ino:897: undefined reference to `WiFiUDP::parsePacket()'

C:\Users\matt\Documents\Arduino\new54/new54.ino:900: undefined reference to `WiFiUDP::read(char*, unsigned int)'

C:\Users\matt\AppData\Local\Temp\arduino_build_510710\sketch\new54.ino.cpp.o: In function `_GLOBAL__sub_D_ipD':

C:\Users\matt\Documents\Arduino\new54/new54.ino:63: undefined reference to `WiFiUDP::~WiFiUDP()'

collect2.exe: error: ld returned 1 exit status

Using library LiquidCrystal_I2C in folder: C:\Users\matt\Documents\Arduino\libraries\LiquidCrystal_I2C (legacy)
Using library Wire at version 2.0 in folder: C:\Users\matt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\libraries\Wire 
exit status 1
Error compiling for board ESP32 Dev Module.

new54.ino (26.4 KB)

mattlogue:
I figured out that it did not like paths in the includes, so I had to delete Arduinos wifi lib so to force it to use the esp32 wifi lib

That shouldn't be necessary. The Arduino IDE will automatically use the ESP32 WiFi library instead of the WiFi library bundled with the Arduino IDE.

mattlogue:
which I took out pathname.

...yet the code you attached still has the path names. Does this mean that the output you posted is from some code that's different from the code you attached?

You really need to spend some time studying the UDP example sketch that comes with the ESP32 WiFi library (File > Examples > WiFi > WiFiUdpClient). You need to create a WiFiUDP object in your sketch and then use that object consistently in your code. Currently you have this commented out line:

//EthernetUDP Udp2;

Which is sort of what you need to do, except it's for the Ethernet library, not the WiFi library.

Then throughout the sketch you use the Udp2 object that line would have created, which is correct. But then inexplicably at line 163 you have this:

 x = Udp.begin(8888);

That is the cause of the goofy "As of Arduino 1.0, the Udp class in the Ethernet library has been renamed to EthernetUdp." error you reported in the unedited version of this thread. This is an attempt by the Arduino IDE to be helpful about some ancient change to the Ethernet library, which is now not helpful at all. That has been reported here:

That's unfortunate and hopefully Arduino will fix it soon, but the solution is simple: Just use any object name other than Udp, as you already did in the rest of your code (Udp2). If you change that line to use the Udp2 object, the error goes away. After that, there is one other error.

However, now you're getting these strange "undefined reference" errors. I can't reproduce that error. I would like to make sure that I'm looking at the code you're actually using. So please post the code you're using.

I got it all working. For some reason I bricked the ESP32. I think some voltage levels were too high. It's a complex project, mostly a bunch of reed switches. One does go into a PC board on my magnetic lock system to determine when someone keys in, that I think was around 5.2V. I should of used a logic level convertor immediately, but I figured wrong that a few minutes would be ok. Heck, even the tone workaround ledcwritetone managed to work.

I used UDP2 and that got rid of the Renamed error.

Then I had to figure out how to use UDP.write because it's different from arduino. It takes a uint_8 instead of a char string.

Thanks Pert. I got rid of the "undenfined ref" errors by taking out the path name. For some reason, IDE still wanted to use the Arduino versions, so I had to move WiFi out of the library folder.

I'm glad to hear it's working!

I sort of suspected that the "undefined reference" errors might have been caused by specifying the full path to the library header files but my understanding was that you had removed the path so I didn't do that when I did the test compilation. I think what happened was that it included the .h files, but didn't also compile the .cpp files of the library where the definitions were.

mattlogue:
Then I had to figure out how to use UDP.write because it's different from arduino. It takes a uint_8 instead of a char string.

That was the "one other error" I mentioned, but I didn't want to get distracted by that before figuring out how to solve the "undefined reference" errors. Great job finding a solution to that error on your own!