Fatal LNK error

I am doing a course on a survival multiplayer game. And I know the problem is because I need the replication dependency module added to my build.cs, but I cannot find anywhere what the module name is for replication

Hey @shotty46290, as far as I know, there is no extra module to add to the Build.cs file to use replication and networking with Unreal. Anyway, to know what is the module name that you want from any class in Unreal you can check it in the documentation. In the top of any class doc you see inside References a “Module” section, that is the name you may need to add to your Build.cs if you are missing a module.

That being said, LNK errors happen when the compiler can’t find something that it is needing, many times is a missing .cpp or .h file. Other times it is fixed by deleting your Binaries, Intermediate, Saved files, then regenerating vs project files and compiling again. I’ve gotten this error when a .cpp method is not named like the .h it is defining, or maybe you copy-pasted a function into your .cpp and the name of the class doesn’t match the one in your header. I mean in the definition it would say:

void WrongClassName::MyCopyPastedMethod() {}

Hope this helps

1 Like

ah there was another course I had went through which stated these LNK errors were linked directly to the modules in the build.cs as they were error linking to that module,

That being said I don’t know how to go about fixing this then, you can see all the code of the project in that screen shot that is all I have added, and I got that error going. it’s the same code as in the course, but his build doesn’t fail. My only guess is something that has changed with their replication system in C++ as in this course he is using version 4.22 or 4.24 I think. I can try regenerating the project files, aside from the missing modules I have never had this error before.

The issue is you’re missing the GetLifetimeReplicatedProps function in your cpp, you need that when dealing with replicated variables, you have Hunger and thirst marked as replicated through the UPROPERTY macro.

Override this in your header

Then in cpp handle your two replicated variables like this, I used RepNum as an example.

1 Like

So do I have to do this for every single variable that needs to be replicated than?

For every variable you need to set it up with the DOREPLIFETIME macro but all of them in that same function, there are other similar macros for more control over what gets replicated like DOREPLIFETIME _CONDITION.