Got UE4 standard classes error when trying to package plugin

Hi guys,

I was trying to package my plugin to users who use binary version of engine to distribute it, but got some strange errors: These are the lines from output log with error string only >> link to the outputlog file <<

I don’t know why compiler says that the default engine classes contains erros, since engine is running normally.
May it be a dependency module problem? Libraries? I don’t know, can you help?

As reference, here is my plug in build cs:

// Copyright 2016 All Rights Reserved.

namespace UnrealBuildTool.Rules
{
    public class NWheeledVehicles : ModuleRules
    {
        public NWheeledVehicles(TargetInfo Target)
        {
            PublicIncludePaths.Add("NWheeledVehicles/Classes");
            PrivateIncludePaths.Add("NWheeledVehicles/Private");

            PublicDependencyModuleNames.AddRange(
                new string[]
                {
                    "Core",
                    "CoreUObject",
                    "Engine",
                    "UnrealEd",
                    "BlueprintGraph",
                    "AnimGraph",
                    "AnimGraphRuntime",
                    "PhysXVehicles",
                    "PhysXVehicleLib",
                }
            );

            SetupModulePhysXAPEXSupport(Target);
        }
    }
}

Just a note: Plugin itself is already compiled on VS15, installed and working normally under Source Version of the engine, but it won’t package or run under binary one.

Hello edsonsantoro,

Based off the name, I’m assuming this is a runtime plugin? If so, you won’t be able to include UnrealEd (This may also include BlueprintGraph and AnimGraph but I’m not sure, I’ve never tried those before) in a packaged build as they are only meant to be used in the editor.

If these are only needed by your plugin while in the editor, you can add them separately with the following syntax

if (UEBuildConfiguration.bBuildEditor == true)
{
DynamicallyLoadedModuleNames.Add("UnrealEd, BlueprintGraph, AnimGraph");
}

Tried that with UnrealEd only, will include BlueprinGraph and AnimGraph to see. Oh, and yes, it is a runtime plugin!

Ok, with DynamicallyLoadedModuleNames it won’t compile, but with PublicDependencyModuleName, it compiles, but fails in package, with same errors. Then, trying to find on forums, came up with this:
PCHUsage = PCHUsageMode.NoSharedPCHs;
And it trows an error that I don’t have a private PCH file. Ok, so I got my hands dirty and separate the runtime code and editor code on two distinct modules, without the PCHUsage hack. Now, its compiling fine, but again, when packaging, I got PCH file error:

ERROR: All source files in module "NWheeledVehicles" must include the same precompiled header first.  Currently "G:\Git\UnrealEngine4.15p4\Engine\Source\Runtime\Core\Public\CoreMinimal.h" is included by most of the source files.  The following source files are not including "G:\Git\UnrealEngine4.15p4
\Engine\Source\Runtime\Core\Public\CoreMinimal.h" as their first include:

So, I built a PCH file, and put that as the first include in all source files, and now VS compiler trows another error that the first include on source files MUST to be it’s own header on each source. Now what?! I’m without options here …

You shouldn’t ever need to create a PCH file. They’re precompiled headers so they’re created by UHT and do not need to be created/edited. I’ve never tried changing the PCHUsageMode to NoSharedPCHs so I’m not sure if I can be of any help if you wish to use that, although it should not be required.

What files are being listed under that error message? It should be listing where you need to include this file.

Hi Matthew, thanks for replying…

Well, if I remove the PCH file, it compiles, but trows the above error message while packaging, that CoreMinimal.h is not included. It is strange, because, if I don’t need a PCH file, why do the Editor asks for it when packaging?

If I use that PCHUsageMode hack, when compiling, (without a PCH file) it gives me the same error when packaging.

I don’t know,I may have missed something on configuration…

Ok, got it working. Added CoreMinimal.h to the list of source files and it compiled and packaged the plugin. But, the behavior when compiling is very strange, because, I needed to add on each source file it’s own header FIRST, and compile it. When it’s done, I’ve added CoreMinimal.h to each of then again, as first include, and it’s fine. But, when I made changes to the module build.cs file, it wont compile anymore, saying that it expected vehicle.h to be first header included on vehicle.cpp, for example… Is that normal?!

That is not normal, if I’m understanding you correctly. What are these vehicle.h and vehicle.cpp files? Are they files that you’ve created? What do they contain?

This is a plugin that extend Physx vehicles plugin. My classes are derived from each of Epic’s plugin. Vehicle.h and Vehicle.cpp was just an example. I only knew that modules depending on other modules was not encouraged after building it, but I’m not sure if it’s the case.

Relying on another module that some users may not have enabled likely isn’t encouraged. I would need specifics instead of just examples if you required more information or assistance.

OK, well, I’ve created a class to vehicles with more than 4 wheels, it’s a derived class of WheeledVehicleMovementComponent, created it’s own AnimInstance that call custom functions from my AdvancedVehicleWheel, which is derived from VehicleWheel. There is an AnimGraphNode too, to handle my AdvancedVehicleWheel. This is the Runtime module. On Editor module, I’ve extended AnimNode_WheelHandler to use my AdvancedVehicleWheel class and properties. The plugin itself is just that, at the moment.

As far as I’m aware, from looking at the code, AnimGraphNode seems to be an editor-only class and can’t be included in a Runtime module. Could you move that to the Editor module?

Sorry Matthew, misspelled those names. Actually, AnimGraphNode is under Editor module, and AnimNode files under Runtime module, just like PhysXVehicles.

I’ve been trying to package default engine plugins, but the only one that packages with success is BlankPlugin, ATM. All the others trow the same error message on OutputLog, asking to include a different header to the source files.
OutPutLog from PhysXVehicles

After speaking with someone on our plugins team, this could be something wrong with some things that changed in 4.15 and we’re currently looking into it. If you can, I would suggest reverting to 4.14 for your plugin development at the moment as it will likely allow you to avoid this issue for now.

Thanks to someone on our Marketplace team who was having widespread game plugin compile issues; It turns out that the issue was related to the “Include What You Use (IWYU)” convention added with 4.15. This is enabled by default in the editor but not in game projects which is what your plugin is being built as.

You can enable it by adding the following line to your .build.cs file and should be able to compile after that.

PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs

Please let me know if this helps.