How to resolve libstdc++.6.dylib dependency

Mojca Miklavec mojca at macports.org
Sat Mar 24 13:07:45 UTC 2018


On 24 March 2018 at 13:35, Andreas Falkenhahn wrote:
> When I compile my C++11 project on a 10.5 PPC system using gcc6 and try to run it on another 10.5 PPC system that doesn't have gcc6 installed, I get an error that a symbol cannot be imported from /usr/lib/libstdc++.6.dylib. I guess this is because the libstdc++.6.dylib that is shipped with 10.5 doesn't contain those new features required by C++11 programs.
>
> So what is the recommended way of getting the libstdc++.6.dylib required by my program onto a user system? Of course I wouldn't like to bother users to install gcc6 from Mac Ports just to be able to run my program. Is there an easier way? Is the latest libstdc++ available as its own package in Mac Ports maybe or what is the suggested way of dealing with this?

You need to compile with ABI 4 compatibility (add
"-D_GLIBCXX_USE_CXX11_ABI=0" to CXXFLAGS) and then relink them to
/usr/lib/libstdc++.6.dylib with install_name_tool.

The first step might soon no longer be required (see
https://github.com/macports/macports-ports/pull/1469), but you'll
probably need to keep running install_name_tool on the resulting
libraries/binaries, I assume that your binaries link against
/opt/local/lib/libstdc++.6.dylib rather than
/usr/lib/libstdc++.*.dylib

Mojca


More information about the macports-users mailing list