This is not a compile error, this is a link error.
Your build setup file probably needs to add a reference to the UI subsystem library/dll.
The easiest way to do this is to cheat a little bit: In the project, choose “add C++ class,” and then create a subclass of UWidget called whatever you want, and have that added to your project.
Once that’s all done, the build files are updated to reference the libraries necessary to link against UI, and then you should be able to link in the other widget functions like you want to do.