Packaging the project


I’v done my little (c++ based) project and now I want to package it … but here comes the troubles …
I want to package it for x64 windows (as a starting point).
First it compiles sources …

... many, many cpp files :)
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: TowerDefence.cpp
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: [28/28] Link TowerDefence.exe
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool:    Creating library D:\UnrealEngine4\Projects\UE4Defender\Binaries\Win64\TowerDefence.lib and object D:\UnrealEngine4\Projects\UE4Defender\Binaries\Win64\TowerDefence.exp
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: -------- End Detailed Actions Stats -----------------------------------------------------------
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: Total build time: 85,18 seconds
MainFrameActions: Packaging (Windows (64-bit)): CommandUtils.Run: Run: Took 85,2301694s to run UnrealBuildTool.exe, ExitCode=0
MainFrameActions: Packaging (Windows (64-bit)): UE4Build.CheckBuildProducts: Build products *******
MainFrameActions: Packaging (Windows (64-bit)): UE4Build.CheckBuildProducts: D:\UnrealEngine4\Projects\UE4Defender\Binaries\Win64\TowerDefence.exe
MainFrameActions: Packaging (Windows (64-bit)): UE4Build.CheckBuildProducts: D:\UnrealEngine4\Projects\UE4Defender\Binaries\Win64\TowerDefence.pdb
MainFrameActions: Packaging (Windows (64-bit)): UE4Build.CheckBuildProducts: D:\UnrealEngine4\Projects\UE4Defender\Build\Receipts\
MainFrameActions: Packaging (Windows (64-bit)): UE4Build.CheckBuildProducts: End Build products *******
MainFrameActions: Packaging (Windows (64-bit)): Project.Build: ********** BUILD COMMAND COMPLETED **********
MainFrameActions: Packaging (Windows (64-bit)): Project.Cook: ********** COOK COMMAND STARTED **********

so it managed to compile the *.exe, now time to cook some levels & UIs, and here comes the trouble …

LogInit:Display: Failure - 325 error(s), 6916 warning(s)

ohh holy sh***

all the errors are related to interaction of c++ code and blueprints

it all starts easy with a warning about

[2015.09.25-21.04.49:505]  0]LogInit:Display: LogLinker:Warning: Can't find file '/Script/TowerDefence'
[2015.09.25-21.04.49:505]  0]LogInit:Display: LogUObjectGlobals:Warning: Failed to load '/Script/TowerDefence': Can't find file '/Script/TowerDefence'

(my game module is TowerDefence, but I dont even have /Script directory under content) - so I dont know what he is looking for …
if it looks for module object, my c++ for it is prety standard:

class TOWERDEFENCE_API FTowerDefenceGameModuleImpl : public FDefaultGameModuleImpl
	virtual void StartupModule() override;
	virtual void ShutdownModule() override;

void FTowerDefenceGameModuleImpl::StartupModule()
        // some code but disabled while WITH_EDITOR is not defined

void FTowerDefenceGameModuleImpl::ShutdownModule()
        // some code but disabled while WITH_EDITOR is not defined

IMPLEMENT_PRIMARY_GAME_MODULE( FTowerDefenceGameModuleImpl, TowerDefence, "TowerDefence" );

and then things go completly crazy

[2015.09.25-21.04.48:700]  0]LoadErrors: Info Failed to load /Script/TowerDefence.PickupHealth Referenced by Medikit
[2015.09.25-21.04.48:701]  0]LogUObjectGlobals:Warning: Failed to load '/Script/TowerDefence': Can't find file '/Script/TowerDefence'
[2015.09.25-21.04.48:701]  0]LogLinker:Warning: Can't find file for asset '/Script/TowerDefence' while loading NULL.
[2015.09.25-21.04.48:701]  0]LoadErrors: Info Failed to load /Script/TowerDefence.PickupHealth Referenced by Medikit
[2015.09.25-21.04.48:701]  0]LogUObjectGlobals:Warning: Failed to load '/Script/TowerDefence': Can't find file for asset '/Script/TowerDefence' while loading NULL.
[2015.09.25-21.04.48:701]  0]LogLinker:Warning: CreateExport: Failed to load Parent for BlueprintGeneratedClass /Game/Models/Pickups/Medikit.Medikit_C

my blueprint Medikit derives from c++ class PickupHealth … any ideas why while cooking my c++ classes are not visible anymore ? (game works just fine inside editor)

and finally all blows up

[2015.09.25-21.04.49:504]  0]LogInit:Display: LogBlueprint:Error: [compiler DefaultDefenderMeleAniBP] Error Could not find a function named "GetState" in 'DefaultDefenderMeleAniBP'.

and tons of anothers from blueprints that cannot find c++ classes anymore

ANY IDEA whats going on, and why I cannot cook package ?
(the only idea I have is that somehow the packaging tool did’nt load the game module and now knows nothing about c++ side of the project, but the module is compilled without any errors)

Thanks for any ideas to check/solutions.


After A LOT of try-and-error checks, compares with other working projects I’v finally managed to get it to package … hell yeah !

The root couse of error was .uproject file
When developing this title I’v used FComponentVisualizer to add some ‘in editor’ visualisations to my components/actors, while this works great it also requires some hackery in app module

class TOWERDEFENCE_API FTowerDefenceGameModuleImpl : public FDefaultGameModuleImpl ...

and inside: void FTowerDefenceGameModuleImpl::StartupModule()

		TSharedPtr<FComponentVisualizer> Visualizer = MakeShareable(new FActorComponentVisualizer());
 		if (Visualizer.IsValid())
			GUnrealEd->RegisterComponentVisualizer(UDrawableActorComponent::StaticClass()->GetFName(), Visualizer);

but this alone will not work as expected until .uproject is hacked with

			"LoadingPhase": "PostEngineInit",

now visualizers work great, and in editor game works great, but this all ****us up when it comes to packaging, soo for packaging it’s need to be reverted to:

			"LoadingPhase": "Default"

and all works fine …

side question, do I realy need 2 uproject files and switch between them for cooking, or is there any solution to have one only ? (but in editor I need load phase to be PostEngineInit to work with some things …)