MALLOC_LEAKDETECTION 1 cannot compile

I am using 4.17.2 on Windows 7 x64. Compiling from source.

I set #define MALLOC_LEAKDETECTION 1 in MallocLeakDetection.h, but the engine source will not compile. I get the following compilation error:

Module.Engine.30_of_38.cpp.obj : error LNK2019: unresolved external symbol "public: static class FMallocLeakDetection & __cdecl FMallocLeakDetection::Get(void)" (?Get@FMallocLeakDetection@@SAAEAV1@XZ) referenced in function "public: virtual void __cdecl TBaseFunctorDelegateInstance<struct TTypeWrapper<void> __cdecl(void),class <lambda_8b5d2b3aca1e89c1bb47a424cb18df99> >::Execute(void)const " (?Execute@?$TBaseFunctorDelegateInstance@$$A6A?AU?$TTypeWrapper@X@@XZV<lambda_8b5d2b3aca1e89c1bb47a424cb18df99>@@$$V@@UEBAXXZ)
Module.Engine.30_of_38.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl FMallocLeakDetection::SetAllocationCollection(bool,int)" (?SetAllocationCollection@FMallocLeakDetection@@QEAAX_NH@Z) referenced in function "public: void __cdecl FMallocLeakReporter::Start(int,float)" (?Start@FMallocLeakReporter@@QEAAXHM@Z)
Module.Engine.30_of_38.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl FMallocLeakDetection::ClearData(void)" (?ClearData@FMallocLeakDetection@@QEAAXXZ) referenced in function "public: virtual void __cdecl TBaseFunctorDelegateInstance<struct TTypeWrapper<void> __cdecl(void),class <lambda_8b5d2b3aca1e89c1bb47a424cb18df99> >::Execute(void)const " (?Execute@?$TBaseFunctorDelegateInstance@$$A6A?AU?$TTypeWrapper@X@@XZV<lambda_8b5d2b3aca1e89c1bb47a424cb18df99>@@$$V@@UEBAXXZ)
Module.Engine.30_of_38.cpp.obj : error LNK2019: unresolved external symbol "public: int __cdecl FMallocLeakDetection::DumpOpenCallstacks(wchar_t const *,struct FMallocLeakReportOptions const &)" (?DumpOpenCallstacks@FMallocLeakDetection@@QEAAHPEB_WAEBUFMallocLeakReportOptions@@@Z) referenced in function "public: int __cdecl FMallocLeakReporter::WriteReport(wchar_t const *,struct FMallocLeakReportOptions const &)" (?WriteReport@FMallocLeakReporter@@QEAAHPEB_WAEBUFMallocLeakReportOptions@@@Z)
Module.Engine.30_of_38.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl FMallocLeakDetection::CheckpointLinearFit(void)" (?CheckpointLinearFit@FMallocLeakDetection@@QEAAXXZ) referenced in function "protected: void __cdecl FMallocLeakReporter::Checkpoint(void)" (?Checkpoint@FMallocLeakReporter@@IEAAXXZ)

I cannot find anyone else who has encountered this issue and resolved it. Any ideas? I need to troubleshoot a memory leak.

Add CORE_API macro to Engine\Source\Runtime\Core\Private\HAL\MallocLeakDetection.h like this:

class CORE_API FMallocLeakDetection