# Added simple UInterface to ShooterGame, now getting linker error

**URL:** <https://forums.unrealengine.com/t/added-simple-uinterface-to-shootergame-now-getting-linker-error/391430>\
**Category:** Community & Industry Discussion\
**Tags:** shootergame, interfaces, unreal-engine, UE4, question\
**Created:** [April 20, 2017, 3:41pm UTC](https://forums.unrealengine.com/t/added-simple-uinterface-to-shootergame-now-getting-linker-error/391430 "2017-04-20T15:41:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MartinL\_Lucid](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MartinL\_Lucid](https://forums.unrealengine.com/u/MartinL_Lucid)\
**Post date:** [April 20, 2017, 3:41pm UTC](https://forums.unrealengine.com/t/added-simple-uinterface-to-shootergame-now-getting-linker-error/391430/1 "2017-04-20T15:41:28Z")

</div>

Hi. I have added a simple interface to the ShooterGame sample (InterfacePickupable.h):

```
#pragma once

#include "InterfacePickupable.generated.h"

UINTERFACE()
class UInterfacePickupable : public UInterface
{
	GENERATED_UINTERFACE_BODY()
};

class IInterfacePickupable
{
	GENERATED_IINTERFACE_BODY()
};

```

And made AShooterPickup inherit from this new interface:

```
// Base class for pickup objects that can be placed in the world
UCLASS(abstract)
class AShooterPickup : public AActor, public IInterfacePickupable
{
	GENERATED_UCLASS_BODY()

```

And now I’m getting a linker error regarding the constructor of the UInterfacePickupable class:

```
[1/4] Compile ShooterGame.generated.cpp
[2/4] Compile Module.ShooterGame.cpp
ShooterGame.generated.cpp
Module.ShooterGame.cpp
[3/4] Link UE4Editor-ShooterGame-Win64-DebugGame.dll
[4/4] Link UE4Editor-ShooterGame-Win64-DebugGame.lib
   Creating library D:\ShooterGame\Intermediate\Build\Win64\UE4Editor\DebugGame\UE4Editor-ShooterGame-Win64-DebugGame.lib and object D:\ShooterGame\Intermediate\Build\Win64\UE4Editor\DebugGame\UE4Editor-ShooterGame-Win64-DebugGame.exp
   Creating library D:\ShooterGame\Intermediate\Build\Win64\UE4Editor\DebugGame\UE4Editor-ShooterGame-Win64-DebugGame.suppressed.lib and object D:\ShooterGame\Intermediate\Build\Win64\UE4Editor\DebugGame\UE4Editor-ShooterGame-Win64-DebugGame.suppressed.exp
ShooterGame.generated.cpp.obj : error LNK2019: unresolved external symbol "public: __cdecl UInterfacePickupable::UInterfacePickupable(class FObjectInitializer const &)" (??0UInterfacePickupable@@QEAA@AEBVFObjectInitializer@@@Z) referenced in function "void__cdecl InternalConstructor<class UInterfacePickupable>(class FObjectInitializer const &)" (??$InternalConstructor@VUInterfacePickupable@@@@YAXAEBVFObjectInitializer@@@Z)
dbsbuild : error : aborting build on error (1120)
D:\ShooterGame\Binaries\Win64\UE4Editor-ShooterGame-Win64-DebugGame.dll : fatal error LNK1120: 1 unresolved externals
ERROR : UBT error : Failed to produce item: D:\ShooterGame\Binaries\Win64\UE4Editor-ShooterGame-Win64-DebugGame.dll

```

What am I doing wrong ?

Thanks.

---

<div class="post-metadata">

**Author:** ![Wurmloch83](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wurmloch83](https://forums.unrealengine.com/u/Wurmloch83)\
**Post date:** [April 20, 2017, 4:50pm UTC](https://forums.unrealengine.com/t/added-simple-uinterface-to-shootergame-now-getting-linker-error/391430/2 "2017-04-20T16:50:17Z")

</div>

I had this issue, too. I could not find the cause of this, but I have a workaround. Add the following code:

```
 UINTERFACE()
 class UInterfacePickupable : public UInterface
 {
     GENERATED_UINTERFACE_BODY()
 };
// insert this:
inline UInterfacePickupable::UInterfacePickupable(const class FObjectInitializer& ObjectInitializer)
    : Super(ObjectInitializer)
{}
 
 class IInterfacePickupable
 {
     GENERATED_IINTERFACE_BODY()
 };

```

I believe this code should be automatically generated, and I suspect this is a bug in the UHT. Maybe you should move this question to the `bug reports` section to get epics attention.

---

<div class="post-metadata">

**Author:** ![MartinL\_Lucid](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MartinL\_Lucid](https://forums.unrealengine.com/u/MartinL_Lucid)\
**Post date:** [April 21, 2017, 8:28am UTC](https://forums.unrealengine.com/t/added-simple-uinterface-to-shootergame-now-getting-linker-error/391430/3 "2017-04-21T08:28:55Z")

</div>

Yes, that was the issue. I looked at Rama’s wiki entry on Interfaces ([A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums](https://wiki.unrealengine.com/Interfaces_in_C%2B%2B)) and that defines the constructor in a cpp file. All working now. Thanks.
