g -4.8 C stdlib dylib

我用gcc48(通过自制软件安装)编译了一个“Hello world”C文件,当我检查链接的动态库时,我看到:

otool -L测试

Test:
    /usr/local/Cellar/gcc48/4.8.1/gcc/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.18.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
    /usr/local/Cellar/gcc48/4.8.1/gcc/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

但是,如果我用苹果提供的gcc编译它,我得到:

Test:
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

我如何得到g -4.8链接/编译苹果提供.dylib?

编辑:我能用/usr/local/Cellar/gcc48/4.8.1/gcc/lib/libstdc .6.dylib分发程序,并使用install_name_tool更改路径吗?

回答(1)

2 years ago

也许你可以尝试使用:

export DYLD_LIBRARY_PATH=...:$DYLD_LIBRARY_PATH

优先考虑苹果的dylibs .