How to package a plugin with a thirdparty library dependency with sources (not prebuilt) ?

I’m trying to package a plugin that has a Thirdparty library dependency (Tinyxml2) in form of source files (not prebuilt).

This is what I have (my parser plugin):
File: MyParser.Build.cs



using UnrealBuildTool;
public class MyParser: ModuleRules
{
    public MyParser(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
        PublicDependencyModuleNames.AddRange( new string] { "Core" }   );
        PrivateDependencyModuleNames.AddRange( new string] { "CoreUObject", "Engine", "Slate", "SlateCore",  "Tinyxml2"  } );
    }
}


Now in the ThirdParty/Tinyxml2 folder I have the .h/.cpp sources AND this file: Tinyxml2.Build.cs



using System.IO;
using System;
using UnrealBuildTool;
public class Tinyxml2 : ModuleRules
{
     public Tinyxml2(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
        PublicDefinitions.Add("TINYXML2_EXPORT"); // This is needed to export tinyxml2 definitions.
    }
}


This compiles, links, and executes OK. But when I try to package MyParser plugin I get this error:



<>c.<PrintExceptionInfo>b__4_1: ==============================================================================
<>c.<PrintExceptionInfo>b__4_0: ERROR: Unable to determine module type for C:\Users\Dani\Documents\PackagedUnreal\Plugins\MyParser\HostProject\Plugins\MyParser\Source\ThirdParty\Tinyxml2.Build.cs
<>c.<PrintExceptionInfo>b__4_0:        (referenced via precompile option -> MyParser.Build.cs)
<>c.<PrintExceptionInfo>b__4_0:        (see C:\Program Files\Epic Games\UE_4.20\Engine\Programs\AutomationTool\Saved\Logs\UBT-UE4Editor-Win64-Development.txt for full exception trace)
<>c.<PrintExceptionInfo>b__4_1:
<>c.<PrintExceptionInfo>b__4_1: BuildException: Unable to determine module type for C:\Users\Dani\Documents\PackagedUnreal\Plugins\MyParser\HostProject\Plugins\MyParser\Source\ThirdParty\Tinyxml2.Build.cs
<>c.<PrintExceptionInfo>b__4_1: (referenced via precompile option -> MyParser.Build.cs)
<>c.<PrintExceptionInfo>b__4_1:    at UnrealBuildTool.UEBuildTarget.FindOrCreateModuleByName(String ModuleName, String ReferenceChain) in C:\Program Files\Epic Games\UE_4.20\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 4200
<>c.<PrintExceptionInfo>b__4_1:    at UnrealBuildTool.UEBuildModule.RecursivelyCreateModulesByName(List`1 ModuleNames, List`1& Modules, CreateModuleDelegate CreateModule, String ReferenceChain) in C:\Program Files\Epic Games\UE_4.20\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildModule.cs:line 738
<>c.<PrintExceptionInfo>b__4_1:    at UnrealBuildTool.UEBuildModule.RecursivelyCreateModules(CreateModuleDelegate CreateModule, String ReferenceChain) in C:\Program Files\Epic Games\UE_4.20\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildModule.cs:line 724
<>c.<PrintExceptionInfo>b__4_1:    at UnrealBuildTool.UEBuildTarget.AddModulesToPrecompile() in C:\Program Files\Epic Games\UE_4.20\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 3137
<>c.<PrintExceptionInfo>b__4_1:    at UnrealBuildTool.UEBuildTarget.PreBuildSetup(UEToolChain TargetToolChain) in C:\Program Files\Epic Games\UE_4.20\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 2670
<>c.<PrintExceptionInfo>b__4_1:    at UnrealBuildTool.UEBuildTarget.Build(BuildConfiguration BuildConfiguration, CPPHeaders Headers, List`1 OutputItems, List`1 UObjectModules, ISourceFileWorkingSet WorkingSet, ActionGraph ActionGraph, EHotReload HotReload, Boolean bIsAssemblingBuild) in C:\Program Files\Epic Games\UE_4.20\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 2021
<>c.<PrintExceptionInfo>b__4_1:    at UnrealBuildTool.UnrealBuildTool.RunUBT(BuildConfiguration BuildConfiguration, String] Arguments, FileReference ProjectFile, Boolean bCatchExceptions) in C:\Program Files\Epic Games\UE_4.20\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 1480
<>c.<PrintExceptionInfo>b__4_1: ==============================================================================

 

How can I configure correctly the Tinyxml2 ThirdParty dependency to package it? Thank you.

Hi Roig
Try using PublicIncludePaths of your container folder with your .h and .cpp.
But at anycase if you want to parse XML there is already a module which does that inside UE

Hello ZkarmaKun.

I have this structure:


Source/
  MyParser
    Private
    Public
  ThirdParty

And when I use:PublicIncludePaths.Add(Path.Combine(ModuleDirectory, “…/ThirdParty”)) It compiles but doesn’t link because it doesn’t compile the .cpp inside ThirdParty folder.

If I use this structure (put ThirdParty inside MyParser folder):


Source/
  MyParser
    ThirdParty
    Private
    Public
  

And using PublicIncludePaths.Add(Path.Combine(ModuleDirectory, “ThirdParty”)) It compiles and links because it finds all the .cpp files. Is this the correct folder structure for a ThirdParty folder inside a plugin? (MyParser is a plugin)

Add ThirdParty/Public to PublicincludePaths
and ThirdParty/Private to PrivateIncludePaths

Btw, Unreal already has a built-in XML parser.

Hello Bruno Xavier.
I did that and it works only with the ThirdParty folder inside the Source/MyParser/ folder as you can read in my last post. (because UHT finds the .cpp and compiles it).

But is this the correct location for the ThirdParty folder? (Source/MyParser/ThirdParty)
Or it has to be (Source/ThirdParty)?

Thanks :slight_smile:

P.D. I know that unreal has it’s own xml parser but I don’t want to change the parsing code if it’s not 100% necessary >_<

UHT will only find the path with a Module directory because you use “Moduledirectory”;

If you want ThirdParty to be found outside module folder you would have to create another module which is unnecessary (I didn’t and passed reviews fine on Marketplace).

I just use “Source/MyModule/ThirdParty/…” and Epic seems to accept it that way.

Thank you!!! :smiley: