What It Means & How to Fix It in UE5 C++
🧠 Why You’re Seeing This Error
LNK2028 is a linker error that means the linker found a reference to a token (function, variable, or method) — but it can’t resolve it, often due to mismatches between managed and native code, or missing implementations in C++ modules.
While it’s more common in /CLR (Common Language Runtime) projects, it can also appear in UE5 projects when:
- You’re integrating managed code (.NET) or using mixed-mode C++/CLI
- You call a function that’s declared but not defined
- You accidentally mix compiler settings (e.g.,
/clr
vs/MT
or/MD
) - You call external functions from DLLs that weren’t linked properly
💥 Example Error Message
txtCopyEditLNK2028: unresolved token (0A000023) "public: void __clrcall MyFunction(void)" referenced in function ...
🛠️ Example Scenario (In UE5)
You’re integrating a C++/CLI module or third-party .NET SDK into your Unreal Engine plugin:
// Declared somewhere in a mixed-mode header
public ref class DotNetHelper {
public:
void DoSomething(); // ❌ Not defined or implemented in managed DLL
};
✅ How to Fix LNK2028 in UE5 – Step-by-Step
✔️ 1. Ensure All Declared Functions Are Fully Defined
Like LNK2019
, this can occur when a function is declared but never implemented.
Fix:
void DotNetHelper::DoSomething() {
// Implementation
}
✔️ 2. Verify Any Managed Code Is Linked Properly
If you’re calling into .NET assemblies, make sure:
- You’ve included the correct
.dll
- The symbols you’re calling are public and not inlined away
- You’ve enabled /clr in your plugin module if required
✔️ 3. Avoid Mixing /clr
and UE5 Runtime Unless Absolutely Necessary
UE5 isn’t designed for managed runtime integration. If you must integrate .NET or C++/CLI:
- Keep it isolated in a separate module
- Use DLL imports or COM interop instead of direct linking
✔️ 4. Use DllImport
or LoadLibrary()
for .NET↔Native Interop
If calling into managed code from native UE5 C++, prefer runtime linking:
HMODULE MyDll = LoadLibrary(L"MyDotNetWrapper.dll");
✅ Summary: How to Fix LNK2028 in UE5
Cause | Fix Example |
---|---|
Function declared but not implemented | Define the function in the correct module |
.NET/CLR integration without linking | Add .NET DLL references properly |
Mixed-mode C++/CLI integration error | Isolate or remove /clr usage from UE5 runtime code |
Using P/Invoke or COM improperly | Use DllImport or LoadLibrary and check for symbol names |