My UE4 (game) project fails to compile if I link against a static library - namely boost.
The error
The compiler (VC++ 2013) complains about not finding the method “FWindowsPlatformMisc::MemoryBarrier()”. And it’s not there! However, it’s in the super class (FGenericPlatformMisc). But why doesn’t the compiler find it then?
Workaround/Fix
To fix this error, I followed a tip from Rama in a different question, which was to just add the following line of code in the header file WindowsPlatformMisc.h (somewhere in the class definition):
static void MemoryBarrier() { }
Question
I don’t like to modify the engine just so that it compiles. Could this be investigated by an Unreal Developer? I guess, FPlatformMisc is a typedef to FWindowsPlatformMisc, and because of that, the compiler doesn’t find the method?
To use any of the Core Misc methods always use FPlatformMisc as a namespace.
So when you type:
FPlatformMisc::MemoryBarrier();
everything should be fine.
The compiler is typedefing FPlatformMisc into the platform specific structs, for example: FWindowsPlatformMisc or FGenericPlatformMisc.
In fact, the Windows MemoryBarrier does nothing. It doesn’t exist in WindowsPlatform, but it is in the GenericPlatform, so the compiler will take that one.
Always use FPlatformMisc. Never use platform specific structs by yourself.
If the compiler can’t find this method anyway, make sure you have “Core” in the module dependencies in Build.cs and you included “Core.h”
You are misunderstanding. It’s not my code, that wants to call FPlatformMisc::MemoryBarrier(), but some UE4 code. It already IS calling FPlatformMisc::MemoryBarrier(), not FWindowsPlatformMisc::MemoryBarrier(), however, that call results in a “undefined method” error since somehow it tries to find this method in the FWindowsPlatformMisc-Class.
I’m using a custom built 4.7.2 build of the engine, which was cloned from the release branch of 4.7.2.
I try to find the place where it was called, but it could take a while since I would have to recompile the engine again (which takes about half an hour on my computer…)