Whenever I attempt to follow the instructions I’ve seen online to create a C++ interface, I can’t get the project to compile correctly. I use the exact same format, but still receive the following error in the generated body macro. Anyone got any suggestions on how to fix this, or what I’m doing wrong?
Couple of shots in the dark:
- Try including Interface.h
- Add your PROJECTNAME_API macro to the IInterface class, but not to the UInterface class.
Not sure if either of these are the cause of the issue, but they are all I can see that is different from my own code.
I am still getting some other bizarre problems, so I’ll try those out…Thanks
I tried adding the Interface.h, but I’m still getting the same problem. After I fixed a typo, the Generated Body stuff “worked”, except that I get these errors in my compiler (line 14 has the GENERATED_UINTERFACE_BODY() line):
SkillUser.h(14): error C2487: ‘GetPrivateStaticClass’ : member of dll interface class may not be declared with dll interface
SkillUser.h(14): error C2487: ‘USkillUser::{ctor}’ : member of dll interface class may not be declared with dll interface
SkillUser.h(14): error C2487: ‘GetPrivateStaticClass’ : member of dll interface class may not be declared with dll interface
SkillUser.h(14): error C2487: ‘USkillUser::{ctor}’ : member of dll interface class may not be declared with dll interface
ERROR : UBT error : Failed to produce item: C:\Users\Will\Documents\GitHub\MyFolder\MyProject\Binaries\Win64\UE4Editor-MyProject-8187.dll
Looks from that like you still have the export macro in front of your USkillUser class definition. I think you need:
UINTERFACE(MinimalAPI)
class USkillUser: public UInterface
{ ... }
class YOURPROJECTNAME_API ISkillUser
{ ... }
Yayyyy, thank you. That was exactly the problem.