Problrm with generated header

I’m trying to compile a dedicated server. But I’m having issues with one of my header files. When it compiles, I get “fatal error: ‘MyMainMenu.generated.h’ file not found”. The include for the generated.h is there in the header, but the header tool isn’t making the generated version. I’m assuming that it’s because the class defined in the file is wrapped in a #if !UE_SERVER. Unfortunately, unwrapping the class creates new problems because the class is derived from UUserWidget which doesn’t exist on a dedicated server.


class MyGame_API UMyMainMenu : public UUserWidget
	UFUNCTION(BlueprintCallable, Category = MainMenu)
	bool OnOpenOptionsMenu();

.. snip ..

Is there a way around this?

UHT only creates a generated header if the related header contains something to generate, i.e.: a UCLASS/USTRUCT/UENUM. You could abuse this behaviour by creating a dummy USTRUCT() outside of the UE_SERVER define. I can’t guarantee this wouldn’t cause some issues, but it’d be the lazy solution.

The proper solution would be to keep client side classes such as UMG widgets in a separate module, then only include that module in your relevant targets. Separating into different modules can be a bit of a daunting task depending on how large your codebase has grown, but it’s worth it.


Creating dummy objects didn’t work. UHT still refuses to make the generated header for some reason.

I’d love to split the Client and Server stuff into separate modules. (That’s the way it should be.) But oh my! That would not be fun. It’s looking like there’s no way around it.

It feels a bit overkill to separate modules (even if it is the proper thing to do) so out of curiosity, I went ahead and built our game in server mode. Even though I include UMG modules, I didn’t get any problems building. But I didn’t try to run, admittedly, as we don’t have a server at all.

What are the problems you were referring to in your original post?

I’ve split the files into 3 groups: Common, Client, and Server. Still having to do some shuffling, but things are working better.

The problems in the OP were rather cryptic. I don’t have a copy of the exact errors any more since I’ve moved onto a new path. But the gist is that any class that had UUserWidget as a parent prevented the dedicated server from building. Wrapping stuff with !UE_Server just moved the problem around. I don’t know why, but UHT refused to build headers when those classes were present. You either ended up with no headers at all, or a bazillion errors during UHT processing.