Using different tool chain than the one used to build Qt

I am kind of confused on the tool chains right now. Specifically, the dependencies on the libraries used.

Say I build Qt 5 with default tool chain which is Apple LLVM (clang) on OS X 10.7. The resulting Qt dylibs depends on /usr/lib/libstdc++.6.dylib which is the only tool chain specific lib from what I can tell.

Then I use a different tool chain, say GCC 4.7 from MacPorts, to build my own application. It will than depend on /opt/local/lib/gcc47/libstdc++.6.dylib.

The resulting application will now link against 2 different copies (and versions) of libstdc++.6.dylib when run. My question is: will this be an issue?

One possible fix (if it's a problem) I can think of is to use GCC and specify -static-libstdc++ and -static-libgcc to build Qt and my app. Is this a good idea? Or can I just use install_name_tool to change my app's dependency to the /usr/lib one?

You can load an arbitrary number of libraries. From that point of view loading /usr/lib/libstdc++.6.dylib and /opt/local/lib/gcc47/libstdc++.6.dylib at the same time is just fine. But of course in this case the symbols provided by those libraries will clash, triggering error messages or nasty side effects.

You can not avoid this clash of symbols by making one or the other library static. So static linking will not help at all.

So the only solution is to use the same exact tool chain with Qt and my app. Right?

This poses an interesting issue for people trying out C++11 features like me. Qt itself doesn't require C++11 enabled. Most people will just install or build it without C++11. Now depending on what compiler you use, the library mix-and-match may happen:

GCC links against libstdc++ with or without C++11 enabled. So it should be fine. But when C++11 is enabled, Clang requires linking against libc++ instead of libstdc++. Now the app and Qt will be loading different ones. I would think that is a BAD thing. :)

What I am trying to do is to use GCC 4.7 instead of Apple's clang sine GCC has better C++11 support. Now I am stuck as the mixed up libraries. I tried building Qt 5 with GCC 4.7 without success. Some part of Qt is using Apple extensions.

So that's a no go. But I finally get it going by building Qt 5 with Apple LLVM-GCC 4.2, then use GCC 4.7 tool chain for C++11 feature. Using install_name_tool, I then change the references to libstc++ in the binary from 4.7 to the system ones. This is probably no kosher but it works so far.

One of my problem is I need to deploy it to 10.6. So I can't use Apple clang since libc++ does not exist in 10.6. Just another monkey wrench Apple throws my way. :)

This forces GCC to link to the system provided libstdc++ and libgcc. Those in OS X 10.6/7 seem to be compatible with GCC 4.7. This makes my resulting app deployable to OS X 10.6 without including my own copies of GCC libraries.