# Linker error with C++ std lib on Linux

**URL:** <https://forums.unrealengine.com/t/linker-error-with-c-std-lib-on-linux/399040>\
**Category:** Platform & Builds\
**Tags:** libraries, Linux, unreal-engine, CPP, question\
**Created:** [June 21, 2017, 5:49am UTC](https://forums.unrealengine.com/t/linker-error-with-c-std-lib-on-linux/399040 "2017-06-21T05:49:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_4a1407a31](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4a1407a31](https://forums.unrealengine.com/u/anonymous_user_4a1407a31)\
**Post date:** [June 21, 2017, 5:49am UTC](https://forums.unrealengine.com/t/linker-error-with-c-std-lib-on-linux/399040/1 "2017-06-21T05:49:55Z")

</div>

I am trying to include a library of my own functions in my Unreal project. I can successfully link the library dynamically, however attempting to use any functions which utilise `std::string` and other parts of the standard library cause a linker error ( `undefined reference`). Linking statically causes a similar error, regardless of whether the functions are used or not.

The library is built with Qt Creator (no Qt libraries though), and is linked against `libstdc++` (tested with both clang and g++).

As far as I can tell, Unreal is trying to use the packaged `libc++` instead of `libstdc++`. Searching online suggests setting a variable called `UE4_LINUX_USE_LIBCXX` to `0` somewhere, but I cannot find any details on how to do this.

Is this the correct approach to be taking, and if so, how/where do I set this variable?

---

<div class="post-metadata">

**Author:** ![RCL](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RCL](https://forums.unrealengine.com/u/RCL)\
**Post date:** [July 18, 2017, 6:07pm UTC](https://forums.unrealengine.com/t/linker-error-with-c-std-lib-on-linux/399040/2 "2017-07-18T18:07:48Z")

</div>

The best approaches to take (in order of preference):

1. rebuild your library to use libc++
2. add a dependency on libstdc++ to your module (PublicAdditionalLibraries.Add(“stdc++”))
3. set the environment variable UE4\_LINUX\_USE\_LIBCXX to 0 and recompile Unreal.

Rationale: if you’re planning to redistribute the resulting Unreal project across Linux distros, you may run into problems with compatibility of libstdc++.so. You cannot bundle libstdc++.so with your Unreal project or link it statically (at least without consulting the lawyer), so you are better off using libc++ which can be freely bundled.
