# Getting linking error when I used a certain method from within Unreal 4 engine source code

**URL:** <https://forums.unrealengine.com/t/getting-linking-error-when-i-used-a-certain-method-from-within-unreal-4-engine-source-code/325392>\
**Category:** Plugins\
**Tags:** engine, unreal-engine, Engine-Source-Code, link, Plugins, question, linking-error\
**Created:** [July 15, 2015, 8:17pm UTC](https://forums.unrealengine.com/t/getting-linking-error-when-i-used-a-certain-method-from-within-unreal-4-engine-source-code/325392 "2015-07-15T20:17:12Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_0d53d466](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0d53d466](https://forums.unrealengine.com/u/anonymous_user_0d53d466)\
**Post date:** [July 15, 2015, 8:17pm UTC](https://forums.unrealengine.com/t/getting-linking-error-when-i-used-a-certain-method-from-within-unreal-4-engine-source-code/325392/1 "2015-07-15T20:17:12Z")

</div>

25\>Module.UFileImporter.cpp.obj : error LNK2019: unresolved external symbol “public: void \_\_cdecl FMaterialUniformExpressionTexture::SetTransientOverrideTextureValue(class UTexture \*)” (?SetTransientOverrideTextureValue@FMaterialUniformExpressionTexture@@QEAAXPEAVUTexture@@@Z) referenced in function “public: class UMaterial \* \_\_cdecl UMyFileImporter::CreateMaterial(class FString)” (?CreateMaterial@UMyFileImporter@@QEAAPEAVUMaterial@@VFString@@@Z)  
25\>C:\Unreal Source\Unreal 7-13-15\I\Engine\Plugins\Developer\UFileImporter\Binaries\Win64\UE4Editor-UFileImporter-Win64-Debug.dll : fatal error LNK1120: 1 unresolved externals

```
25>ERROR : UBT error : Failed to produce item: C:\Unreal Source\Unreal 7-13-15\I\Engine\Plugins\Developer\UFileImporter\Binaries\Win64\UE4Editor-UFileImporter-Win64-Debug.dll
25> Total build time: 46.48 seconds
25>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "..\..\Build\BatchFiles\Build.bat UE4Editor Win64 Debug" exited with code -1.

```

When I use the method SetTransientOverrideTextureValue I get this error. I haven’t figured out why yet. I know this method is used within the engine but I’m trying to forcefully switch out textures in a material that I have imported in outside the project.

Here’s the code:

```
UMaterial* mat = NewObject<UMaterial>();
	ERHIFeatureLevel::Type FeatureLevelsToUpdate[1] = { GetWorld()->FeatureLevel };
	int32 NumFeatureLevelsToUpdate = 1;
	for (int32 i = 0; i < NumFeatureLevelsToUpdate; i++)
	{
		FMaterialResource* Resource = mat->GetMaterialResource(FeatureLevelsToUpdate[i]);
		const TArray<TRefCountPtr<FMaterialUniformExpressionTexture>>* ExpressionsByType[2] =
		{
			&Resource->GetUniform2DTextureExpressions(),
			&Resource->GetUniformCubeTextureExpressions()
		};
		for (int32 TypeIndex = 0; TypeIndex < ARRAY_COUNT(ExpressionsByType); TypeIndex++)
		{
			for (FMaterialUniformExpressionTexture* Expression : *ExpressionsByType[TypeIndex])
			{
				const bool bAllowOverride = false;
				UTexture* Texture = NULL;
				Expression->GetGameThreadTextureValue(mat, *Resource, Texture, bAllowOverride);
				Expression->SetTransientOverrideTextureValue(Import(Path));
			}
		}

	}

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [July 16, 2015, 3:54pm UTC](https://forums.unrealengine.com/t/getting-linking-error-when-i-used-a-certain-method-from-within-unreal-4-engine-source-code/325392/2 "2015-07-16T15:54:07Z")

</div>

Hey

Where is the code that you posted located in the engine? I was able to find SetTransientTextureOverride() but I did not find a SetTransientOverrideTextureValue() function in the engine. Additionally, I’m not sure I understand what you’re trying to accomplish. It sounds as though the textures you want to use are not assets in the project, is this accurate? Are you able to import the textures into the project rather than trying to access them from somewhere else?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0d53d466](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0d53d466](https://forums.unrealengine.com/u/anonymous_user_0d53d466)\
**Post date:** [July 16, 2015, 4:38pm UTC](https://forums.unrealengine.com/t/getting-linking-error-when-i-used-a-certain-method-from-within-unreal-4-engine-source-code/325392/3 "2015-07-16T16:38:41Z")

</div>

What I am ultimately trying to do is allow for runtime importation of files outside the project, in this case images. I will takes these images and make them into UTexture2D. From here I was trying to see if it would be easier to create my own UMaterial and UMaterialInterface or use preexisting ones. I wanted to switch out textures on a static mesh component when the application first runs  
I know this is digging into a lot of stuff which is probably violating the EULA but these edits are for in house use and not distrabution.

The code I posted was from my own method heavily based from material.cpp’s overrideTexture method

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0d53d466](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0d53d466](https://forums.unrealengine.com/u/anonymous_user_0d53d466)\
**Post date:** [July 16, 2015, 4:41pm UTC](https://forums.unrealengine.com/t/getting-linking-error-when-i-used-a-certain-method-from-within-unreal-4-engine-source-code/325392/4 "2015-07-16T16:41:28Z")

</div>

After digging farther into the files I realized that the material variable is missing a lot of components and it would probably be easier to use an already existing material. Although i’m not sure there the material and the textures are actually linked so finding how to change the material on a method is my next step

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [July 16, 2015, 6:48pm UTC](https://forums.unrealengine.com/t/getting-linking-error-when-i-used-a-certain-method-from-within-unreal-4-engine-source-code/325392/5 "2015-07-16T18:48:33Z")

</div>

Hey

It should be possible to switch a texture during runtime however it would not be an easy task. To do so you would need to set up a dynamic material instance and then change the texture parameter. If the texture being used is saved outside of the project then you need to hardcode the path to the texture. If the texture is saved on a web server you would need to include the URL to the texture as well as make sure that the game is able to connect to the internet to retrieve the texture. Depending on the number of images and reasoning, it may be a better option to bring the images into the editor to make referencing them easier.

Cheers

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0d53d466](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0d53d466](https://forums.unrealengine.com/u/anonymous_user_0d53d466)\
**Post date:** [July 16, 2015, 7:36pm UTC](https://forums.unrealengine.com/t/getting-linking-error-when-i-used-a-certain-method-from-within-unreal-4-engine-source-code/325392/6 "2015-07-16T19:36:27Z")

</div>

Thank you very much  
There will be a proxy that will provide the path to where the pictures are located. It won’t be the same pictures everytime.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0d53d466](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0d53d466](https://forums.unrealengine.com/u/anonymous_user_0d53d466)\
**Post date:** [July 16, 2015, 7:47pm UTC](https://forums.unrealengine.com/t/getting-linking-error-when-i-used-a-certain-method-from-within-unreal-4-engine-source-code/325392/7 "2015-07-16T19:47:29Z")

</div>

When I pick the parent material for the dynamic material that seems to override the dynamic material and only show the texture of the parent  
I’m not sure if that means that its not actually getting a texture to show or if something else is going on

---

<div class="post-metadata">

**Author:** ![Lovecraft\_K](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lovecraft\_K](https://forums.unrealengine.com/u/Lovecraft_K)\
**Post date:** [July 17, 2015, 2:03pm UTC](https://forums.unrealengine.com/t/getting-linking-error-when-i-used-a-certain-method-from-within-unreal-4-engine-source-code/325392/8 "2015-07-17T14:03:16Z")

</div>

Hi KikyoPorter -

I’ve been helping on this question and I want to make sure we are understanding you correctly. You should be creating a new Dynamic Material Instance referencing the base material as a template. You cannot simply force a material to be dynamic, the engine views those separately and a Dynamic Material needs a base to derive from.

Is this how you are handling the coding?

Thank You for the clarification -

Eric Ketchum

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0d53d466](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0d53d466](https://forums.unrealengine.com/u/anonymous_user_0d53d466)\
**Post date:** [July 17, 2015, 2:17pm UTC](https://forums.unrealengine.com/t/getting-linking-error-when-i-used-a-certain-method-from-within-unreal-4-engine-source-code/325392/9 "2015-07-17T14:17:22Z")

</div>

Yes so I created a dynamic Material Instance with the parent material being the original material

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [July 17, 2015, 3:19pm UTC](https://forums.unrealengine.com/t/getting-linking-error-when-i-used-a-certain-method-from-within-unreal-4-engine-source-code/325392/10 "2015-07-17T15:19:05Z")

</div>

So it sounds like the setup is correct, does the original material show as expected before trying to change it? How are you using the DMI after creating it? Could you post the code that you’re using to change the DMI material as well as how the code is called?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0d53d466](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0d53d466](https://forums.unrealengine.com/u/anonymous_user_0d53d466)\
**Post date:** [July 17, 2015, 6:27pm UTC](https://forums.unrealengine.com/t/getting-linking-error-when-i-used-a-certain-method-from-within-unreal-4-engine-source-code/325392/11 "2015-07-17T18:27:07Z")

</div>

I actually found a way to import an image from my hard drive and its showing up. I just have to make sure I just make a copy of the original material and not a pointer otherwise when I change it, it will change the original material and cause errors.
