Linker Error on deriving from Webbrowser widget

Hi ,

I am geting linker error when I attempt to create a C++ class deriving from Webbrowser class. I want to add the following function in the newly created class.

 UFUNCTION(BlueprintCallable, Category="Web Browser")
  FString GetURL() const;

FString UCustomWebBrowser::GetURL() const
{
    if ( WebBrowserWidget.IsValid() )
    {
        return WebBrowserWidget->GetUrl();
    }
    
    return "";
}

But this is giving error →

Undefined symbols for architecture x86_64
“SWebBrowser::GetUrl() const”, referenced from:
UCustomWebBrowser::GetURL() const in CustomWebBrowser.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

this is related to the line WebBrowserWidget->GetUrl() , because if I comment the line , I don’t get the error anymore.

SWebBrowser is in module ‘WebBrowser’, do you add this depend module in your build.cs file of your project?

you are a life saver…thanks a million :smiley:

you’re welcome,and you can close this question :slight_smile:

Hi, we’re trying to do the same thing, expose the GetURL of SWebBrower in the our CustomWebBrowse widgetr; can you please explain us steps to subclass the WebBrowser Widget to access the current URL? We tried to create a new C++ subclass of WebBrowser from the UE editor, but when we try to complie, VS shows us errors like: "use of undefined type ‘SWebBrowser’ and ‘GetUrl’: is not a member of 'TSharedPtr. Can you please address us in right direction? Thanks.

Hello,I’d like to help you,but this question is closed so if you need more information about this link error,please send email with your error image to me :1441842473@qq.com
Usually the link error is because you not add the module ‘WebBrowser’ in your game module’s .build.cs file. You can add this name such as:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore","WebBrowser" });