Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

LNK 2001 error caused by virtual interface

I've been trying to implement a simple interface into my project Damageable. It contains a single virtual method Damage(float damage). Everything appears to be fine with intellisense, however when the project is compiled in the editor it throws the following error

Error D:\GamesCreate\Reflections\Reflections\Binaries\Win64\UE4Editor-Reflections-1327.dll : fatal error LNK1120: 1 unresolved externals Error ReflectionsCharacter.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AReflectionsCharacter::Damage(float)" (?Damage@AReflectionsCharacter@@UEAAXM@Z) Error Reflections.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AReflectionsCharacter::Damage(float)" (?Damage@AReflectionsCharacter@@UEAAXM@Z)

my code for my interface is as follows

 // Fill out your copyright notice in the Description page of Project Settings.
 #pragma once
 #include "CoreMinimal.h"
 #include "DamageableInterface.generated.h"
 // This class does not need to be modified.
 class UDamageableInterface : public UInterface
 class REFLECTIONS_API IDamageableInterface
     // Add interface functions to this class. This is the class that will be inherited to implement this interface.
     virtual void Damage(float damage) = 0;

It seems like such a simple task to create a pure virtual function within an interface, but I cannot figure out how to implement it. I think it has something to do with the function being virtual, however I don't know where to go from here. Why is this error being thrown and what can I do to fix it?

Product Version: UE 4.16
more ▼

asked Jan 10 '19 at 12:45 AM in C++ Programming

avatar image

3 1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Based on the log output, it looks like it's your AReflectionsCharacter class that's throwing the error.

The "unresolved external symbol" error often appears when you declare a function in your class header file, but don't define it in any source (.cpp) files.

In your case, my guess is, you've set your AReflectionsCharacter class to inherit from your new interface, but haven't yet defined and declared an override for the interface's Damage(...) function.

Have a look at that and let me know if that's what's going on.

more ▼

answered Jan 10 '19 at 04:03 PM

avatar image

1.2k 4 5 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question