Using libraries with std::shared_ptrs

I got mine working. But it was caused by the fact that my third party dll was using a different version of the c++ CRT. It was compiled using Visual Studio 2017, while unreal was compiled using VS 2019 compiler. By compiling both my dll and unreal with vs 2019, and hiding my DLL behind a c style interface, it seemed to work.

I found these two articles extremely helpful:

From what I gather, you might be able to use shared pointers without a restrictive interface, but its recommended not to do so. Passing anything beyond simple data structures and pointers past dll boundaries doesn’t appear to be recommended, although perhaps that only applies to cases where they were built using different compilers or different CRT. In any case, you should avoid it wherever possible, along with any templated objects.

By me using different compilers, it appears that causes my dll to try to use the CRT runtime it was built with, different heap than unreal’s heap. Resulting in heap corruption.

I’m no expert, so I don’t have the best details, but I can at least walk you through what worked in my case. I will continue to refine and improve my project in the future, and see if I can do it without using an extra module interface

EDIT: Nope, looks like using a module interface is definitely required in my case. Trying to use my dll without it caused my heap corruption issues again.