Why does libc++’s implementation of std::string take up 3x memory as libstdc++?

Here is a short program to help you explore both kinds of memory usage of std::string: stack and heap. #include <string> #include <new> #include <cstdio> #include <cstdlib> std::size_t allocated = 0; void* operator new (size_t sz) { void* p = std::malloc(sz); allocated += sz; return p; } void operator delete(void* p) noexcept { return std::free(p); … Read more

C++ project compiled with modern compiler, but linked against outdated libstdc++

Anyway, the resulting artifacts appear to be linked with system default version of libstdc++: Yes. The devtoolset-6-gcc-c++ package provides a custom version of GCC that uses a special linker script instead of a dynamic library for libstdc++.so. That means the binaries it produces do not depend on the newer libstdc++.so.6 and can be run on … Read more

Linking g++ 4.8 to libstdc++

When you link with your own gcc you need to add an extra run-time linker search path(s) with -Wl,-rpath,$(PREFIX)/lib64 so that at run-time it finds the shared libraries corresponding to your gcc. I normally create a wrapper named gcc and g++ in the same directory as gcc-4.8 and g++-4.8 which I invoke instead of gcc-4.8 … Read more