Mixing old and newer libstdc++ at runtime

Mikhail Novosyolov m.novosyolov at rosalinux.ru
Wed Apr 8 06:26:34 PDT 2020


Hi all,

I have been interested in how to use a newer libstdc++ for programs that require it to be built and run when the system version of libstdc++ is not new enough.

I have a DragonFlyBSD box, where gcc 8 is the default compiler. I installed gcc9 (pkg install gcc9) and it suggests to attach its newer libstdc++.so.6 by RPATH:

> Message from gcc9-9.2.0_1:
>
> --
> To ensure binaries built with this toolchain find appropriate versions
> of the necessary run-time libraries, you may want to link using
>
>   -Wl,-rpath=/usr/local/lib/gcc9
>
> For ports leveraging USE_GCC, USES=compiler, or USES=fortran this happens

So, if I build something like this, a newer libstdc++ from /usr/local/lib/gcc9/libstdc++.so.6 will be loaded.

But what will happen when this binary links with other libraries which were linked with an older system version of libstdc++? when dlopen'ing them? The newer libstdc++ will be used instead of the older one that those other libraries were built against.  Are any problems expected and/or known to happen?

In theory, there may be problems, but I have not been able to find any of them.



More information about the Users mailing list