Can't use WITH_EDITOR methods

I’m trying to port a plugin, made for UE 4.18, to UE 4.19.
The problem I’m fighting with is that a lot of things have changed in USkeletalMesh (and other related classes) in UE 4.19.

Now I think I’ve solved a lot of problems and have the last one. I need to call the method BuildFromLODModel in the class FSkeletalMeshLODRenderData.
The problem is that method is preceded by the compiler directive #if WITH_EDITOR, so what happens is that it has no errors but, when I try to compile my code, compiler says it can not resolve the reference to that method… so, how can I call that method when I’m not in the editor? How can I compile that code without removing that directive (and compiling the engine)?

Hey.

Function that’s wrapped with WITH_EDITOR will never exist in non-editor build targets. So obviously you won’t be able to use that in such cases. However, if your plugin (or the part that needs to call this function) is meant for editor, then you can also wrap that execution with WITH_EDITOR and everything should work fine.

I’m trying to build it with “Development Editor” as solution configuration, but nothing…

It seems to be ok. Maybe you’re missing an include? Could you show exact error from your output window?

If you mention “not resolve” i assume you having linker errors, this has nothing to do with WITH_EDITOR, linker simply have issue to find this method in engine binaries to link your plugin module to it. In UE4 linker errors are usaly caused by 2 issues:

Either you missing module dependency in build script (*.build.cs) in this case you need to check in which module this function is, you can check that by looking on path where header file is, for example UnrealEngine/Engine/Source/Runtime/EngineMessages/Public/ the module name is before Public so in this case EngineMessages.

2nd the header file is in Privete directory so it not exposed to binery linking and can’t be accessed from other module… it can’t be helped. Some things are not exposed to less useful things reduce linking time, usally those function are internal for internal use.