# Build Error After Importing ONNX Runtime Library

**URL:** <https://forums.unrealengine.com/t/build-error-after-importing-onnx-runtime-library/502901>\
**Category:** Plugins\
**Tags:** unreal-engine, crash, CPP, UE4-27, question\
**Created:** [February 28, 2022, 8:31pm UTC](https://forums.unrealengine.com/t/build-error-after-importing-onnx-runtime-library/502901 "2022-02-28T20:31:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![DANIEL1523](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/daniel1523/32/88711_2.png) [@DANIEL1523](https://forums.unrealengine.com/u/DANIEL1523)\
**Post date:** [February 28, 2022, 8:31pm UTC](https://forums.unrealengine.com/t/build-error-after-importing-onnx-runtime-library/502901/1 "2022-02-28T20:31:27Z")

</div>

Hi, I’m trying to import ONNX Runtime to UE4 to allow me to run ONNX AI models inside UE4. I get build errors however and would appreciate any help to rectify them.

To quickly detail my process, I add `PrivateIncludePathModuleNames.AddRange(new string[] { "ORT" });` to my project’s build.cs file, thus, enabling the plugin. I have added the include headers, .libs, and .dlls from the [ORT zip](https://github.com/microsoft/onnxruntime/releases) called onnxruntime-win-x64-1.10.0.zip to my plugins folder and added the following to my plugin’s build.cs file:

```auto
PublicIncludePaths.AddRange(
			new string[] {
				"$(PluginDir)\\" + "include"
			}
			);

		PublicAdditionalLibraries.AddRange(
			new string[] {
				"$(PluginDir)\\" + "LibraryBinaries\\" + "Windows\\" + "onnxruntime.lib",
				"$(PluginDir)\\" + "LibraryBinaries\\" + "Windows\\" + "onnxruntime_providers_shared.lib"
			}
			);

		PublicDelayLoadDLLs.AddRange(
			new string[] {
				"onnxruntime.dll",
				"onnxruntime_providers_shared.dll"
			}
			);

		RuntimeDependencies.Add("$(PluginDir)\\LibraryBinaries\\Windows\\onnxruntime.dll");
		RuntimeDependencies.Add("$(PluginDir)\\LibraryBinaries\\Windows\\onnxruntime_providers_shared.dll");

```

It builds correctly, but when I add `#include <onnxruntime_cxx_api.h>` to my main .cpp I get the following build error:

```auto
Build started...
1>------ Build started: Project: ImplementingONNX, Configuration: Development_Editor x64 ------
1>Building ImplementingONNXEditor...
1>Using Visual Studio 2019 14.29.30140 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133) and Windows 10.0.19041.0 SDK (C:\Program Files (x86)\Windows Kits\10).
1>Building 4 actions with 24 processes...
1> [1/4] TestingONNX.cpp
1>C:\Users\dmiln\UE4\ImplementingONNX\Plugins\ORT\include\onnxruntime_c_api.h(121): warning C4005: 'ORT_API': macro redefinition
1> C:\Users\dmiln\UE4\ImplementingONNX\Intermediate\Build\Win64\UE4Editor\Development\ImplementingONNX\Definitions.ImplementingONNX.h(289): note: see previous definition of 'ORT_API'
1> [2/4] UE4Editor-ImplementingONNX.lib
1> Creating library C:\Users\dmiln\UE4\ImplementingONNX\Intermediate\Build\Win64\UE4Editor\Development\ImplementingONNX\UE4Editor-ImplementingONNX.lib and object C:\Users\dmiln\UE4\ImplementingONNX\Intermediate\Build\Win64\UE4Editor\Development\ImplementingONNX\UE4Editor-ImplementingONNX.exp
1> [3/4] UE4Editor-ImplementingONNX.dll
1> Creating library C:\Users\dmiln\UE4\ImplementingONNX\Intermediate\Build\Win64\UE4Editor\Development\ImplementingONNX\UE4Editor-ImplementingONNX.suppressed.lib and object C:\Users\dmiln\UE4\ImplementingONNX\Intermediate\Build\Win64\UE4Editor\Development\ImplementingONNX\UE4Editor-ImplementingONNX.suppressed.exp
1>TestingONNX.cpp.obj : error LNK2019: unresolved external symbol OrtGetApiBase referenced in function "void __cdecl `dynamic initializer for 'public: static struct OrtApi const * const Ort::Global<void>::api_''(void)" (??__E?api_@?$Global@X@Ort@@2PEBUOrtApi@@EB@@YAXXZ)
1>C:\Users\dmiln\UE4\ImplementingONNX\Binaries\Win64\UE4Editor-ImplementingONNX.dll : fatal error LNK1120: 1 unresolved externals
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(45,5): error MSB3073: The command ""C:\Program Files\Epic Games\UE_4.27\Engine\Build\BatchFiles\Build.bat" ImplementingONNXEditor Win64 Development -Project="C:\Users\dmiln\UE4\ImplementingONNX\ImplementingONNX.uproject" -WaitMutex -FromMsBuild" exited with code 6.
1>Done building project "ImplementingONNX.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

```

The code on line 289 signified in the build error above is: `#define ORT_API DLLIMPORT`  
The code at (45,5) signified in the build error above is: `<Exec Command="$(NMakeBuildCommandLine)" Condition="'$(NMakeUseOemCodePage)' == 'true' and '$(NMakeBuildCommandLine)'!=''"/>`

I’ve tried the suggestions at [Error in c\_cxx samples: unresolved external symbol "struct OrtApi const \* const Ort::g\_api" · Issue #2081 · microsoft/onnxruntime · GitHub](https://github.com/microsoft/onnxruntime/issues/2081), but these don’t help. I don’t implement the .pdb files, but I don’t think these are important are they?  
Any suggestions on how to fix this are greatly appreciated, thanks so much

---

<div class="post-metadata">

**Author:** ![Oleg304](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Oleg304](https://forums.unrealengine.com/u/Oleg304)\
**Post date:** [March 18, 2022, 1:13pm UTC](https://forums.unrealengine.com/t/build-error-after-importing-onnx-runtime-library/502901/2 "2022-03-18T13:13:01Z")

</div>

[ONNX in Unreal 5](https://github.com/EpicGames/UnrealEngine/tree/5.0.0-preview-2/Engine/Plugins/Experimental/NeuralNetworkInference/Source/ThirdParty/ONNX_1_10_1)

---

<div class="post-metadata">

**Author:** ![DANIEL1523](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/daniel1523/32/88711_2.png) [@DANIEL1523](https://forums.unrealengine.com/u/DANIEL1523)\
**Post date:** [April 4, 2022, 12:50pm UTC](https://forums.unrealengine.com/t/build-error-after-importing-onnx-runtime-library/502901/3 "2022-04-04T12:50:35Z")

</div>

Do you have a working link for what you’re trying to provide please?

---

<div class="post-metadata">

**Author:** ![Oleg304](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Oleg304](https://forums.unrealengine.com/u/Oleg304)\
**Post date:** [April 4, 2022, 2:24pm UTC](https://forums.unrealengine.com/t/build-error-after-importing-onnx-runtime-library/502901/4 "2022-04-04T14:24:38Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/4/f/24f9c07f5d51d3037b5bf339a72b540cfd2e8a38.png)  
You can enable it by the plugins interface or compile from the source (you should be registered on EpicGame github). It’s for UE 5.0.0. Please check the UE version. Also exist for other versions

---

<div class="post-metadata">

**Author:** ![DANIEL1523](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/daniel1523/32/88711_2.png) [@DANIEL1523](https://forums.unrealengine.com/u/DANIEL1523)\
**Post date:** [April 8, 2022, 10:06am UTC](https://forums.unrealengine.com/t/build-error-after-importing-onnx-runtime-library/502901/5 "2022-04-08T10:06:37Z")

</div>

Wow thanks so much, I hadn’t heard of this. Do you know of any docs for how to use it? I can’t seem to find any, maybe because it’s so new/in alpha?

---

<div class="post-metadata">

**Author:** ![DANIEL1523](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/daniel1523/32/88711_2.png) [@DANIEL1523](https://forums.unrealengine.com/u/DANIEL1523)\
**Post date:** [April 8, 2022, 10:09am UTC](https://forums.unrealengine.com/t/build-error-after-importing-onnx-runtime-library/502901/6 "2022-04-08T10:09:36Z")

</div>

I’ve found the docs: [NeuralNetworkInference | Unreal Engine Documentation](https://docs.unrealengine.com/5.0/en-US/API/Plugins/NeuralNetworkInference/)

Hopefully it becomes clearer how to use this plugin as time passes. Right now I’m not sure where to start!

---

<div class="post-metadata">

**Author:** ![Oleg304](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Oleg304](https://forums.unrealengine.com/u/Oleg304)\
**Post date:** [April 8, 2022, 1:06pm UTC](https://forums.unrealengine.com/t/build-error-after-importing-onnx-runtime-library/502901/7 "2022-04-08T13:06:44Z")

</div>

I am waiting for tutorial 🙂 )  
[https://medium.com/@gineshidalgo99/nni-tutorial-how-to-officially-run-deep-learning-on-unreal-engine-5-445ad25f19cd](https://medium.com/@gineshidalgo99/nni-tutorial-how-to-officially-run-deep-learning-on-unreal-engine-5-445ad25f19cd)  
But also thinking to start using without it. Maybe next week - before I should prepare other stuff

---

<div class="post-metadata">

**Author:** ![Oleg304](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Oleg304](https://forums.unrealengine.com/u/Oleg304)\
**Post date:** [April 9, 2022, 1:44pm UTC](https://forums.unrealengine.com/t/build-error-after-importing-onnx-runtime-library/502901/8 "2022-04-09T13:44:18Z")

</div>

Looks like this plugin you can use only in c++ mode or need additinal code for BP interactions.  
The plugin allows import onnx model with one input (just drag and drop) but does not have any BP functions ;(

---

<div class="post-metadata">

**Author:** ![DANIEL1523](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/daniel1523/32/88711_2.png) [@DANIEL1523](https://forums.unrealengine.com/u/DANIEL1523)\
**Post date:** [April 9, 2022, 3:50pm UTC](https://forums.unrealengine.com/t/build-error-after-importing-onnx-runtime-library/502901/9 "2022-04-09T15:50:47Z")

</div>

Thank you for the link! I’ll be waiting for that tutorial too. I also had a quick look at the plugin inside UE5 and, agreed, it looks like there’s minimal BP functionality ☹ Please let me know if you make any progress using C++ and I’ll try do the same. What do you mean by just drag and drop? Drag and drop what where?

---

<div class="post-metadata">

**Author:** ![DANIEL1523](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/daniel1523/32/88711_2.png) [@DANIEL1523](https://forums.unrealengine.com/u/DANIEL1523)\
**Post date:** [April 19, 2022, 10:33am UTC](https://forums.unrealengine.com/t/build-error-after-importing-onnx-runtime-library/502901/10 "2022-04-19T10:33:51Z")

</div>

New tutorial out: [Use ONNX Runtime and OpenCV with Unreal Engine 5 New Beta Plugins - YouTube](https://youtu.be/LX1w_etaftY)
