UnrealBuildTool - "Could not find definition for module" error when packaging c++ plugin

Hi,

I created a c++ plugin in UE5.4.3 VS2022 with dependency on another local/project plugin under the same project as follows:

TestProject
    -Plugins
        -A
        -B

Where B depends on A, ie in B.build.cs, I included plugin A in the PrivateDependencyModuleNames as follows:

PrivateDependencyModuleNames.AddRange(
	new string[]
	{
		...,
		"A",
	}
	);

The project compiled without any error in VS2022 and tested successfully in Unreal Editor. However, when I tried to package plugin B in Unreal Editor under Edit->Plugins and selecting plugin B under the Project section → Package, it failed with the following:

Could not find definition for module 'PluginA', (referenced via Target -> PluginB.Build.cs)
CompilationResultException: Could not find definition for module 'PluginA', (referenced via Target -> PluginB.Build.cs)
   at UnrealBuildTool.RulesAssembly.CreateModuleRules(String ModuleName, ReadOnlyTargetRules Target, String ReferenceChain, ILogger Logger) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\System\RulesAssembly.cs:line 441
   at UnrealBuildTool.RulesAssembly.CreateModuleRules(String ModuleName, ReadOnlyTargetRules Target, String ReferenceChain, ILogger Logger) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\System\RulesAssembly.cs:line 437
   at UnrealBuildTool.RulesAssembly.CreateModuleRules(String ModuleName, ReadOnlyTargetRules Target, String ReferenceChain, ILogger Logger) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\System\RulesAssembly.cs:line 437
   at UnrealBuildTool.RulesAssembly.CreateModuleRules(String ModuleName, ReadOnlyTargetRules Target, String ReferenceChain, ILogger Logger) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\System\RulesAssembly.cs:line 437
   at UnrealBuildTool.RulesAssembly.CreateModuleRules(String ModuleName, ReadOnlyTargetRules Target, String ReferenceChain, ILogger Logger) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\System\RulesAssembly.cs:line 437
   at UnrealBuildTool.UEBuildTarget.CreateModuleRulesAndSetDefaults(String ModuleName, String ReferenceChain, ILogger Logger) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 5339
   at UnrealBuildTool.UEBuildTarget.FindOrCreateModuleByName(String ModuleName, String ReferenceChain, ILogger Logger) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 5463
   at UnrealBuildTool.UEBuildTarget.<>c__DisplayClass71_0.<PreBuildSetup>b__0(String Name, String RefChain) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 3384
   at UnrealBuildTool.UEBuildModule.RecursivelyCreateModulesByName(List`1 ModuleNames, List`1& Modules, Boolean& bDependsOnVerse, CreateModuleDelegate CreateModule, String ReferenceChain, List`1 ReferenceStack, ILogger Logger) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildModule.cs:line 1274
   at UnrealBuildTool.UEBuildModule.RecursivelyCreateModules(CreateModuleDelegate CreateModule, String ReferenceChain, List`1 ReferenceStack, ILogger Logger) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildModule.cs:line 1137
   at UnrealBuildTool.UEBuildBinary.CreateAllDependentModules(CreateModuleDelegate CreateModule, ILogger Logger) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildBinary.cs:line 162
   at UnrealBuildTool.UEBuildTarget.PreBuildSetup(ILogger Logger) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 3382
   at UnrealBuildTool.UEBuildTarget.Create(TargetDescriptor Descriptor, Boolean bSkipRulesCompile, Boolean bForceRulesCompile, Boolean bUsePrecompiled, UnrealIntermediateEnvironment IntermediateEnvironment, ILogger Logger) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 1392
   at UnrealBuildTool.UEBuildTarget.Create(TargetDescriptor Descriptor, BuildConfiguration BuildConfiguration, ILogger Logger) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 1226
   at UnrealBuildTool.BuildMode.CreateMakefileAsync(BuildConfiguration BuildConfiguration, TargetDescriptor TargetDescriptor, ISourceFileWorkingSet WorkingSet, ILogger Logger) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 1114
   at UnrealBuildTool.BuildMode.BuildAsync(List`1 TargetDescriptors, BuildConfiguration BuildConfiguration, ISourceFileWorkingSet WorkingSet, BuildOptions Options, FileReference WriteOutdatedActionsFile, ILogger Logger, Boolean bSkipPreBuildTargets) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 396
   at UnrealBuildTool.BuildMode.ExecuteAsync(CommandLineArguments Arguments, ILogger Logger) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 252
   at UnrealBuildTool.UnrealBuildTool.Main(String[] ArgumentsArray) in D:\Program Files\Epic Games\UE_5.4\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 660
WriteFileIfChanged() wrote 0 changed files of 0 requested writes.

I’ve tested a few different scenarios, I even created 2 independent simple plugins A & B where B does not rely on A and each can be packaged successfully on their own but as soon as I included A in B.build.cs, B will faile to package with the same error. I have searched and read through several related posts in and outside of the forum but couldn’t find an answer. Please help…

After more testing, I was able to package plugin B if I package plugin A first and move the packaged A into [UE install dir]\Engine\Plugins\Marketplace first.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.