Enlace diferentes bibliotecas estándar de C ++ en Mac OS X

Ahora que pueden existir múltiples bibliotecas estándar de C ++ en Mac OS X, ahora parece una situación bastante caótica. De acuerdo ahttps://stackoverflow.com/a/8457799/1772681Mezclar libstdc ++ y libc ++ resultará en un error de enlace, que atrapa una situación tan peligrosa y es algo bueno.

Por otro lado, todavía hay 2 situaciones que requieren más investigación, y he creado algunos casos de prueba para esto en github gist (https://gist.github.com/manphiz/7195515). Confirma que la mezcla de bibliotecas dinámicas que enlazan a libstdc ++ (ya sea desde el sistema o vanilla GNU GCC) y libc ++ (sistema) generará un error de enlace. Sin embargo, si una biblioteca dinámica se vincula con el sistema libstdc ++, mientras que otra biblioteca dinámica se vincula con la GNU GCC libstdc ++ y luego se vincula ambos a un binario, también funciona en mi caso de prueba simple, incluso en tiempo de ejecución.

$ make -f Makefile.system_gnu 
g++-4.8 -g -Wall -fPIC -o main.o -c main.cc
g++-4.8 -g -Wall -fPIC -o test_a.o -c test_a.cc
g++-4.8 -dynamiclib -o libtest_a.dylib test_a.o
clang++ -g -Wall -fPIC "-stdlib=libstdc++" -o test_b.o -c test_b.cc
clang++ -dynamiclib "-stdlib=libstdc++" -o libtest_b.dylib test_b.o
g++-4.8 -o test main.o -L. -ltest_a -ltest_b

$ ./test
main_test_a_test_b

Así que aquí se necesita un consejo:

¿Podemos mezclar el sistema libstdc ++ y el GNU GCC libstdc ++ manualmente? Si no, ¿cuándo causará problemas?¿Podemos mezclar el sistema libc ++ y el Clang libc ++ creado manualmente? Si no, ¿cuándo causará problemas?

Información de los compiladores:

$ clang -v
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix

$ gcc-4.8 -v
Using built-in specs.
COLLECT_GCC=gcc-4.8
COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc48/4.8.2/libexec/gcc/x86_64-apple-darwin13.0.0/4.8.2/lto-wrapper
Target: x86_64-apple-darwin13.0.0
Configured with: ../configure --build=x86_64-apple-darwin13.0.0 --prefix=/opt/homebrew/Cellar/gcc48/4.8.2 --enable-languages=c,c++,fortran,java,objc,obj-c++ --program-suffix=-4.8 --with-gmp=/opt/homebrew/opt/gmp4 --with-mpfr=/opt/homebrew/opt/mpfr2 --with-mpc=/opt/homebrew/opt/libmpc08 --with-cloog=/opt/homebrew/opt/cloog018 --with-isl=/opt/homebrew/opt/isl011 --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --enable-plugin --disable-nls --with-ecj-jar=/opt/homebrew/opt/ecj/share/java/ecj.jar --enable-multilib
Thread model: posix
gcc version 4.8.2 (GCC)

El sistema es Mac OS X 10.9.

Respuestas a la pregunta(1)

Su respuesta a la pregunta