# Unreal can't load .lib file and gets stuck

**URL:** <https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196>\
**Category:** C++\
**Tags:** third-party-librarie, unreal-engine, crash, bug-report, editor, CPP, question\
**Created:** [April 3, 2024, 10:23am UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196 "2024-04-03T10:23:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![444\_Nuits](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/444_nuits/32/901354_2.png) [@444\_Nuits](https://forums.unrealengine.com/u/444_Nuits)\
**Post date:** [April 3, 2024, 10:23am UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/1 "2024-04-03T10:23:54Z")

</div>

Hi,  
I’m trying to use my imitation.lib in a game demo project for my plugin here’s my build.cs for it :

```c++
public class ImitationLib : ModuleRules
{

	private string ModulePath
	{
		get { return ModuleDirectory; }
	}

	private string ThirdPartyPath
	{
		get { return Path.GetFullPath (Path.Combine (ModulePath, "../ThirdParty/" ) ); }
	}

	public ImitationLib(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
        bUseRTTI = true;
        bEnableExceptions = true;

        PublicIncludePaths.AddRange(
			new string[] {
				// ... add public include paths required here ...
			}
			);

		PublicDependencyModuleNames.AddRange(
			new string[]
			{
				"Core",
				// ... add other public dependencies that you statically link with here ...
        "CoreUObject",
        "Engine",
        "InputCore",
        "HeadMountedDisplay",

				//added modules
				"SignalProcessing",
        "AudioMixer",
        "XmlParser",
				"AudioCapture",
        "UMG"
      }
			);

    PrivateIncludePaths.AddRange(
      new string[]
      {
        "ImitationLib/Public",
        "ImitationLib/Private/"
      }
      );

    PrivateDependencyModuleNames.AddRange(
			new string[]
			{
				"CoreUObject",
				"Engine",
				"Slate",
				"SlateCore",
				"InputCore",
				"EditorStyle",
				// ... add private dependencies that you statically link with here ...	
				"AudioCapture"
      }
			);
		
		
		DynamicallyLoadedModuleNames.AddRange(
			new string[]
			{
				// ... add any modules that your module loads dynamically here ...
			}
			);

			//get platform target
			string Platform = Target.Platform.ToString();
			bool LibSupportedBool = false;

			//set a libSupportedBool if target platform is Win64
			if (Platform == "Win64")
                LibSupportedBool = true;
            else
                LibSupportedBool = false;

		PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "Lib", "FreqAEC.lib"));
    PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "Lib", "imitation.lib"));
    PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "Lib", "ippcore.lib"));
    PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "Lib", "ippcoremt.lib"));
    PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "Lib", "ipps.lib"));
    PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "Lib", "ippsmt.lib"));
    PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "Lib", "ippvm.lib"));
    PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "Lib", "ippvmmt.lib"));
    PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "Lib", "ippch.lib"));
    PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "Lib", "ippchmt.lib"));
    PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "Lib", "libfftw3f-3.lib"));
    PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "Lib", "RingBufferLib.lib"));
    PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "Include"));
    PublicDefinitions.Add(string.Format ("WITH_JUCE_BINDING={0}", LibSupportedBool ? 1 : 0 ) );
	}
}

```

So when I don’t use any function from my imitation.lib everything works fine but then when I use one function from it seems to load it indefinitely and gets stuck at 75% when I launch my vsSolution (because I use the predefault loading phase in my.uplugin I think) :

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/1/1/011e30d55e039417c0e71e5186779e3f40e96805.jpeg)

Adding an imitation.lib’s function and compiling it from the live coding console doesn’t work either and the console gets stuck at “Creating Patch Image” :

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/4/d/34dade2d022300b73b2fe14173628e61837935d4.png)

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [April 3, 2024, 11:05am UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/2 "2024-04-03T11:05:47Z")

</div>

How are you calling the lib functions?

When accessing normal c++ with it’s includes are you using the correct switches to allow includes & third party content?

```auto

THIRD_PARTY_INCLUDES_START
// example includes
#include <windows.h>
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <fstream>

#if PLATFORM_WINDOWS
#include "Windows/AllowWindowsPlatformTypes.h"
#endif

/// custom code here

#if PLATFORM_WINDOWS
#include "Windows/HideWindowsPlatformTypes.h"
#endif

THIRD_PARTY_INCLUDES_END

```

You can’t just call your lib functions directly from unreal. You can expose them through static functions.

---

<div class="post-metadata">

**Author:** ![444\_Nuits](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/444_nuits/32/901354_2.png) [@444\_Nuits](https://forums.unrealengine.com/u/444_Nuits)\
**Post date:** [April 3, 2024, 12:13pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/3 "2024-04-03T12:13:58Z")

</div>

My AudioCaptureActor in my game needs to access MyCaptureComponent from my plugin :  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/b/5/9b57ed8857498067a7e1cb86487540866d0505ca.png)

MyCaptureComponent need to use one of the imitation lib’s function (here imi\_trans\_transform):

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/5/a/c5aaafca118d180f228c2a7a9e6bcce8ce85d331.png)

Here’s the header of MyCaptureComponent :

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/f/2/df2cecdc1ff2a3fb9fe325c3ab768c07842fe5ca.png)

And here’s my ImitationLibPCH.h:

```c++
#pragma once

// Unreal
#include "Engine.h"
#include "AudioMixerDevice.h"
#include "Modules/ModuleManager.h"
#include "Internationalization/Internationalization.h"
#include "SlateBasics.h"
#include "GameFramework/Character.h"
#include "GameFramework/Actor.h"
#include "Components/ActorComponent.h"
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
#include "Logging/LogCategory.h"

// ImitationLib
THIRD_PARTY_INCLUDES_START
#include "ImitationTools.h"
#include "Muvoc/muvoc_system.h"
#include "Muvoc/imi_transform_rt.h"
#include "Muvoc/imi_trans_modes.h"
#include "Muvoc/muvoc_frequencyAEC.h"
#include "RingBuffer/RingBufferConsummer.h"
#include "RingBuffer/RingBufferNoLock.h"
#include "RingBuffer/RingBufferReadLock.h"
THIRD_PARTY_INCLUDES_END

#include "IImitationLib.h"
#include "AECFloat.h"

```

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [April 3, 2024, 1:45pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/4 "2024-04-03T13:45:43Z")

</div>

does imi\_trans\_transform call any standard library functions internally?  
If so perhaps it’s execution should be isolated in it’s area.  
I made a dll linker a while back where I had to push parts of the code to their own section for it to work ok with std

[CreateAndLinkDLLTutBFL.zip](https://forums.unrealengine.com/uploads/short-url/kK4E1ICAN4mG2l3y7z2RVySgUjP.zip) (1.7 KB)

---

<div class="post-metadata">

**Author:** ![444\_Nuits](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/444_nuits/32/901354_2.png) [@444\_Nuits](https://forums.unrealengine.com/u/444_Nuits)\
**Post date:** [April 3, 2024, 1:52pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/5 "2024-04-03T13:52:58Z")

</div>

Yeah I think it does could you explain how can I use your Linker or if you have any use of case to give me ? (I don’t know if I was clear but my imitationLib (containing the imi\_imi\_transform symbol is a static lib so a .lib, not a dll)

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [April 3, 2024, 1:54pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/6 "2024-04-03T13:54:49Z")

</div>

The dll example is just to show how you can shift the execution of the function to a space that has the correct setup for sdt and windows.h type function execution if it’s needed for the functions internals.

---

<div class="post-metadata">

**Author:** ![444\_Nuits](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/444_nuits/32/901354_2.png) [@444\_Nuits](https://forums.unrealengine.com/u/444_Nuits)\
**Post date:** [April 3, 2024, 2:24pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/7 "2024-04-03T14:24:59Z")

</div>

I don’t think it’s right because I use strcpy() in my component which is a standard lib function and this works fine it’s just when I call a symbol from my imitationLib.lib that makes my editor crash so I’m not sure it’s linked to the fact that I use standard Lib functions

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [April 3, 2024, 2:28pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/8 "2024-04-03T14:28:02Z")

</div>

Could it maybe be a duplicate function name used in the lib? Unreal doesn’t normally allow the use if of namespaces so maybe it’s an already defined error that is triggered just silently?

Also the module itself has it’s own loading phase. if you set it to

```auto
"LoadingPhase": "Default",

```

then that might counteract the plugin loading phase or maybe it too has to match the preDefault? Not sure what the module is set at at the moment.

---

<div class="post-metadata">

**Author:** ![444\_Nuits](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/444_nuits/32/901354_2.png) [@444\_Nuits](https://forums.unrealengine.com/u/444_Nuits)\
**Post date:** [April 3, 2024, 2:36pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/9 "2024-04-03T14:36:45Z")

</div>

The module(ImitationLib plugin) is set at predefault

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/a/f/1af47b623cecea5116fc67b79ce911223ff0a088.png)

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [April 3, 2024, 2:48pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/10 "2024-04-03T14:48:55Z")

</div>

Perhaps another phase could work?

 ![phases](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/6/7/b67da1186cbfddde2e437a0ea6e63ad49669b006.png)  
You could see if earlier phases change when the engine loading stops (other than 75%)

Also does you module cpp file use IMPLEMENT\_MODULE & FDefaultModuleImpl?

```auto
IMPLEMENT_MODULE(FDefaultModuleImpl, IImitationLib);

```

there are no copy paste mistakes maybe by accident from the main project definition?

---

<div class="post-metadata">

**Author:** ![444\_Nuits](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/444_nuits/32/901354_2.png) [@444\_Nuits](https://forums.unrealengine.com/u/444_Nuits)\
**Post date:** [April 3, 2024, 3:07pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/11 "2024-04-03T15:07:10Z")

</div>

Changing the loading phase to earliestpossible just doesn’t launch the splashscreen of UE editor and post engine init just lock it at the same percentage (75)

And yeah, my Module cpp is fine :

```c++
#include "ImitationLib.h"

DEFINE_LOG_CATEGORY(LibLog);

#define LOCTEXT_NAMESPACE "FImitationLibModule"

FImitationLib::FImitationLib()
{
	
}

void FImitationLib::StartupModule()
{
	// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
	UE_LOG(LibLog, Warning, TEXT("ImitationLib: Log Started"));
}

void FImitationLib::ShutdownModule()
{
	// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
	// we call this function before unloading the module.
	UE_LOG(LibLog, Warning, TEXT("ImitationLib: Log Ended"));
}

#undef LOCTEXT_NAMESPACE

IMPLEMENT_MODULE(FImitationLib, ImitationLib)

```

---

<div class="post-metadata">

**Author:** ![444\_Nuits](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/444_nuits/32/901354_2.png) [@444\_Nuits](https://forums.unrealengine.com/u/444_Nuits)\
**Post date:** [April 3, 2024, 3:10pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/12 "2024-04-03T15:10:42Z")

</div>

This is so frustrating like there is no log of nothing it just freezes because of my .lib but no clue of why it would do that when there was no problem implementing it in other software

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [April 3, 2024, 3:21pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/13 "2024-04-03T15:21:12Z")

</div>

Unreal in some cases will actually stop loading at 75% due to un-compiled or corrupt blueprint actors. It’s a bit stupid. There should be more information to why it stops loading.

---

<div class="post-metadata">

**Author:** ![444\_Nuits](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/444_nuits/32/901354_2.png) [@444\_Nuits](https://forums.unrealengine.com/u/444_Nuits)\
**Post date:** [April 3, 2024, 3:37pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/14 "2024-04-03T15:37:23Z")

</div>

I’ll try moving my plugin to a blank project and see if this was the issue

---

<div class="post-metadata">

**Author:** ![444\_Nuits](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/444_nuits/32/901354_2.png) [@444\_Nuits](https://forums.unrealengine.com/u/444_Nuits)\
**Post date:** [April 3, 2024, 3:47pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/15 "2024-04-03T15:47:27Z")

</div>

Yeah on a blank project it gets stuck at 90% I’m pretty sure it’s still the step where the editor loads the plugin

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [April 3, 2024, 4:13pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/16 "2024-04-03T16:13:03Z")

</div>

Maybe try different loading phases on the fresh project

---

<div class="post-metadata">

**Author:** ![444\_Nuits](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/444_nuits/32/901354_2.png) [@444\_Nuits](https://forums.unrealengine.com/u/444_Nuits)\
**Post date:** [April 5, 2024, 12:58pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/17 "2024-04-05T12:58:52Z")

</div>

Up my includes are correctly guarded by #include “AllowWindowsPlatformTypes.h”  
but it’s still doesn’t work

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [April 5, 2024, 1:19pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/18 "2024-04-05T13:19:29Z")

</div>

Hmm seeing as there is no direct information from the editor then maybe add a try catch statement inside of your library function call (make it silent so no throwing) and try saving out the error message to a file.

Or see it the try catch is triggered with a breakpoint on load?

---

<div class="post-metadata">

**Author:** ![444\_Nuits](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/444_nuits/32/901354_2.png) [@444\_Nuits](https://forums.unrealengine.com/u/444_Nuits)\
**Post date:** [April 5, 2024, 1:37pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/19 "2024-04-05T13:37:03Z")

</div>

So Something like that ? (the functions of my .lib begins with imi\_) :

```c++
void UMyCaptureComponent::SetImitationDirectory(FString targetName)
{
	try {
		UE_LOG(LogTemp, Warning, TEXT("SetImitationDirectory: %s"), *GetModelPath(targetName));

		//add try and catch to check if the function of the .lib is loaded
		if (!m_imiHandle)
			imi_trans_delete(m_imiHandle);

		strcpy_s(m_imiParams.voice_dir, TCHAR_TO_ANSI(*GetModelPath(targetName)));

		imi_number_of_trans_handle(1);

		m_imiHandle = 0;
		/** Constructor for the zero delay method */
		imi_trans_zd_new(m_imiHandle, &m_imiParams, mSampleRate, mSampleRate);
	}
	catch (const std::exception& e)
	{
		FString ErrorMessage = FString::Printf(TEXT("Exception caught: %s"), UTF8_TO_TCHAR(e.what()));

		// Write error message to log file
		FString LogFilePath = FPaths::ProjectLogDir() + TEXT("ExceptionLog.txt");
		FFileHelper::SaveStringToFile(ErrorMessage, *LogFilePath);

		UE_LOG(LogTemp, Error, TEXT("%s"), *ErrorMessage);
	}
	catch (...)
	{
		// Catch any other exceptions
		FString ErrorMessage = TEXT("Unknown exception caught in SetImitationDirectory");

		// Write error message to log file
		FString LogFilePath = FPaths::ProjectLogDir() + TEXT("ExceptionLog.txt");
		FFileHelper::SaveStringToFile(ErrorMessage, *LogFilePath);

		UE_LOG(LogTemp, Error, TEXT("%s"), *ErrorMessage);
	}
}

```

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [April 5, 2024, 1:43pm UTC](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196/20 "2024-04-05T13:43:33Z")

</div>

Give it a test. I know that unreal normally ommits try / catch but see if the debugger is triggered by it.

[Next page](https://forums.unrealengine.com/t/unreal-cant-load-lib-file-and-gets-stuck/1785196.md?page=2)
