Download

Inconsistent dll linkage in tutorial.

So… I’m following the Player Input and Pawns tutoral found at Player Input and Pawns | Unreal Engine Documentation

#1 error: you need to add #include <Runtime/Engine/Private/Camera/CameraComponent.cpp> to get it to compile at all. (easily fixed)

#2 error: the compiler flags the MyPawn.cpp file for not including MyPawn.h first if the files included on the page are taken litterally (easily fixed)

#3 error: Many errors of the following form:

|Error|C4273|‘UCameraComponent::UCameraComponent’: inconsistent dll linkage|HowTo_PlayerInput|D:\Epic\UE_4.27\Engine\Source\Runtime\Engine\Private\Camera\CameraComponent.cpp|31||

… which, while I’m an old C++ hand, I don’t play too much in the M$ world — or in the Unreal world (yet) — so I have no idea how to resolve this last error.

Help?

I noticed after posting this that the example said “4.9” as the Unreal version. I gather that this was a pre-5.0 beta/alpha — so I loaded the 5.0 release candidate and re-attempted the tutorial.

Same result. Please help.

Is this not the right place to ask this? Is there another comparable tutorial I should do instead?

Unreal Engine switched to an ‘include what you use’ style some time ago. Probably after that tutorial was made. Previously, you automatically included a lot of core stuff from a header I believe was called “Core.h”. Now you automatically include very little from “CoreMinimal.h”.

It’s likely that you are missing some includes as a result.

I imagine that your third problem is a result of this as well. I highly recommend using ‘Rider for Unreal’ as your IDE instead of Visual Studio. It’s a lot better and will help you with includes as well.

Another issue you might face following an older tutorial is deprecated functions.
That said if you know your way around documentation and so on you should be able to complete the tutorial. I would however recommend you find a newer one.

And yes this forum is the right place to ask.

Edit: As a sidenote, the include you posted for UCameraComponent can be simplified. You should be able to find the include for any base class in the documentation.
Example: UCameraComponent | Unreal Engine Documentation

Thank-you for the confirmation, firstly. I gather posting on a long weekend was part of the reason for it taking awhile to find the right person :).

Now… obviously, Question 3 is the meat of my problem (I was commenting on the other two in case someone might improve the tutorial).

On “Rider” … link? Also… do tutorials exist? Also, will Rider let me use clang?

But on the current setup, is this a “library include problem” ? I really mean it when I say that I don’t do DLL stuff hardly ever. Staring at the errors and looking at my code — is it a “thing” because I’m subclassing a virtual class that may exist in a DLL — I know enough of C++ internal magic to understand that could be a problem — but it also must be a solved problem. What’s the magic incantation?

Lastly, I just want a tutorial that is subclassing a pawn for me…

Rider: https://www.jetbrains.com/lp/rider-unreal/

It’s free right now. Probably paid in the future. I don’t know if you can use clang with it. It works like you’d expect an IDE to work, and it’s specifically made for Unreal.

It’s difficult to tell without you linking the code / class causing the error.

How did you go about creating your current pawn subclass?

To create a subclass of Pawn, you just go to your UE4 editor and create a new c++ class and pick APawn as your parent class.

OK. To create this subclass I was exactly (as possible) following the tutorial above. In UE4 (or I also tried 5) I create c++ class (a little harder to find than the tutorial says) and then I choose pawn as the parent class. I then added the code in the tutorial to the class — including the UCameraComponent.

Anyways… the output of the VS2019 build looks like:

I can try to replicate your issue when I get home today and figure out what you need to do to solve this. UE 4.9 is a lot different from UE 4.27, and I’m not sure why they keep tutorials as old as this one, as they’ll be deprecated.

I found more recent tutorial: UE4 C++ Tutorial - How To Move Pawns - Pawn Movement - UE4 / Unreal Engine 4 Intro to C++ - YouTube

I havn’t watched this video, but DevEnabled is a good tutor.