Anytime I attempt to use the std library in UE5 I’m getting unresolved external symbol errors. For example, on a new project if I instantiate a std::string in an Actor I get the following linker error:
Another example, if I attempt to instantiate a std::mutex and std::unique_lock I get:
MyActor.cpp.obj : error LNK2019: unresolved external symbol _Mtx_init_in_situ referenced in function "protected: virtual void __cdecl AMyActor::BeginPlay(void)" (?BeginPlay@AMyActor@@MEAAXXZ)
MyActor.cpp.obj : error LNK2019: unresolved external symbol _Mtx_destroy_in_situ referenced in function "public: __cdecl std::mutex::~mutex(void)" (??1mutex@std@@QEAA@XZ)
MyActor.cpp.obj : error LNK2019: unresolved external symbol _Mtx_lock referenced in function "protected: virtual void __cdecl AMyActor::BeginPlay(void)" (?BeginPlay@AMyActor@@MEAAXXZ)
MyActor.cpp.obj : error LNK2019: unresolved external symbol _Mtx_unlock referenced in function "protected: virtual void __cdecl AMyActor::BeginPlay(void)" (?BeginPlay@AMyActor@@MEAAXXZ)
MyActor.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl std::_Throw_C_error(int)" (?_Throw_C_error@std@@YAXH@Z) referenced in function "protected: virtual void __cdecl AMyActor::BeginPlay(void)" (?BeginPlay@AMyActor@@MEAAXXZ)
Is this intended behavior or am I missing something in my dev environment? I’m trying to develop a plugin which builds against a static library that uses the std library, and UBT failing to find std lib symbols is blocking me unfortunately.
I’m on a Windows machine running Windows 10. I’ve tested using UE 5.0 and 5.1, as well as on Windows 11. I’ve manually downloaded the 2010, 2012, 2013, and 2015 Visual C++ CRT’s with no luck.
Thanks for the reply. I understand that it isn’t recommended to use STL containers within UE5. However, is it true that you’re not able to use any STL container at all without getting stdlib linker errors? From speaking with colleagues they are able to build with UBT when using STL containers just fine, so I think my dev setup is incorrect
To be more specific with what I’m trying to do, I’m trying to integrate a pre-built third-party library that uses the std library. When I link against this pre-built static library in my module I get several linker errors for std methods. This led me to try to use any STL container in my project and I still get linker errors, which seems strange
What’s strange is I’m unable to build the main project module using UBT if I use any of the stdlib containers (ex. std::string). This leads me to think that UBT is unable to find the CRT. Do you know of any way to check that UBT is able to find stdlib?
I’m just building through VS, so maybe there is something specific to the UBT - while having a look around I found this article which was quite informative, it highlights near the bottom about the problems with third-party-stdlib-sharing:
But doesn’t offer a solution for this.
Does it work ok with stdlib if you build from a new simple project built in VS? If that fails too - it’s a good indication you’ll be needing to try and reinstall the lastest CRT…
Thanks for the link, I’ve actually already read that article. It was super informative on understanding ABI issues when integrating dynamic third-party libraries. However, I’m hitting linker issues when compiling the module itself using UBT
From your suggestion I’ve tried to build the module from VS directly and it appears to build even if I’m using STL containers! I can even modify the file and then later build using live coding and I no longer get any linker issues. Strangely enough it seems like I only get std linker issues if I don’t build within VS at all, but only trigger the build by pressing ctrl + alt + f11. Do you usually build your modules directly from within VS or do you also use the ctrl + alt + f11 shortcut while UE5 is running?
To be more clear the steps to repro the issue for me are:
create new C++ project
create Actor within main project module
instantiate a std::string in the Actor (ex. in the BeginPlay() method)
press ctrl + alt + f11 to trigger build
observe linker issues with unresolved std symbols
To fix the linker issues, I close UE5 and then trigger a build directly from within VS (ctrl + b). This seems to also trigger UBT (since the VS sln was created by UE), but this time the build passes. I can then make modifications and compile using ctrl + alt + f11 while UE5 is running and it seems to build fine.
Need to test further when linking against my static library, but it seems like triggering a build from within VS while UE5 isn’t running causes UBT to be able to find the std CRT.
Appreciate you taking the time to repro - super weird that this is the behavior of live coding. Marking this as resolved as the workaround is to ensure building through VS first.
I wouldn’t mark this as resolved. In UE5.3 the same issue exists, but, you can’t work around it by closing the UE Editor. When you Rebuild your Project it builds fine but doing a normal Build fails with the same error.