[BUG] Unreal Fails To Add Slate Widget Class

Hello and goodnight;

I have spent some time studying and utilizing Unreal 4, and now I am trying to work with Slate Widgets, however, I cannot proceed because the Unreal Editor continues to fail on creating the class.

I am trying to add it by following these steps:

->File->Add Code To Project;

->Choose “Slate Widget”;

->Give the class a name, ANY UNUSED name, don’t touch the PATH;

->Click “CREATE”

I then get a error message window saying:

"Failed to add class MyCompoundWidget. Failed to automatically hot reload the 'ProgrammingGuide' module."

The previous windows now says:

"The name MyCompoundWidget is already used by another class."

Upon further investigation, Unreal does create the files, however, it fails to compile them, here is a small log:

Info Performing 2 actions (4 in parallel)
Info SMyCompoundWidget.cpp
Error d:\workspace\unrealeditor\programmingguide\source\programmingguide\SMyCompoundWidget.h(9)  : error C2504: 'SCompoundWidget' : base class undefined
Error d:\workspace\unrealeditor\programmingguide\source\programmingguide\SMyCompoundWidget.h(12)  : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error d:\workspace\unrealeditor\programmingguide\source\programmingguide\SMyCompoundWidget.h(12)  : error C4183: 'SLATE_BEGIN_ARGS': missing return type; assumed to be a member function returning 'int'
Error d:\workspace\unrealeditor\programmingguide\source\programmingguide\SMyCompoundWidget.h(16)  : error C2144: syntax error : 'void' should be preceded by ';'
Error d:\workspace\unrealeditor\programmingguide\source\programmingguide\SMyCompoundWidget.h(16)  : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error d:\workspace\unrealeditor\programmingguide\source\programmingguide\SMyCompoundWidget.h(16)  : error C4183: 'SLATE_END_ARGS': missing return type; assumed to be a member function returning 'int'
Error d:\workspace\unrealeditor\programmingguide\source\programmingguide\SMyCompoundWidget.h(16)  : error C2143: syntax error : missing ',' before '&'
Error D:\Workspace\UnrealEditor\ProgrammingGuide\Source\ProgrammingGuide\SMyCompoundWidget.cpp(7)  : error C2144: syntax error : 'void' should be preceded by ';'
Error D:\Workspace\UnrealEditor\ProgrammingGuide\Source\ProgrammingGuide\SMyCompoundWidget.cpp(7)  : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error D:\Workspace\UnrealEditor\ProgrammingGuide\Source\ProgrammingGuide\SMyCompoundWidget.cpp(7)  : error C2143: syntax error : missing ',' before '&'
Error D:\Workspace\UnrealEditor\ProgrammingGuide\Source\ProgrammingGuide\SMyCompoundWidget.cpp(17)  : fatal error C1004: unexpected end-of-file found
Info -------- End Detailed Actions Stats -----------------------------------------------------------
Info ERROR: UBT ERROR: Failed to produce item: D:\Workspace\UnrealEditor\ProgrammingGuide\Binaries\Win64\UE4Editor-ProgrammingGuide-6704.dll
Info Cumulative action seconds (8 processors): 0.00 building projects, 0.10 compiling, 0.00 creating app bundles, 0.00 generating debug info, 0.00 linking, 0.00 other
Info UBT execution time: 3.68 seconds

I have tried editing my “.Build.cs” to include the Slate and SlateCore to the project, but still, makes no difference…
I am assuming I have a linking problem, so yeah, if anyone has idea, he/she is very welcome to guess whats wrong!

My System:

Microsoft Windows 8.1 PRO w/ media center (x64);

Unreal Editor 4.7.5 build 4.7.5-2503383+++depot+UE4-Releases+4.7;

Microsoft Visual Studio 2013 Ultimate (x64) *even though it was not used to build the files;

Specs:

AMD FX-9590 4.7-5.0Ghz Octa-Core;

Asus AMD/ATI Radeon R9 290X 4GB GDDR5;

32gb 2400Mhz Corsair Dominator DDR3 RAM;

Generic 3TB 7200RPM HDD;

ANY HELP IS APPRECIATED!

You posted in the wrong section. It should be the section, Bug Report.

As well as adding Slate and SlateCore to your .Build.cs file (which you’ve already done), you’ll also need to include SlateBasics.h inside your games PCH file (this will be called “YourProject.h”, and likely contain an existing include for EngineMinimal.h - just include it after that).

thanks! i just wish they put that on the tutorials too (they just tell about the build.cs) TT-TT
also, I am very sorry for posting this as a bug, I got gery confused by the app behavior!

Thanks for the answer. I spent about 5 hours just now finding this post, and trying to understand what the answer meant, and I’m not unfamiliar with c++ makefiles.

I have to say, from reading the docs it’s not obvious that we need to manually hack 2 files to extend a class of the engine. The docs seem to imply all that needs to be done is to “select the class in the class wizard” and regenerate the project buildfiles.

The weird thing is the correct modules are automatically added to the project file by the wizard. It just seems the the system that generates the build.cs and PCH file doesn’t do the job correctly.

Thank you so much , you saved my day !