首页 > 解决方案 > 解决方法 --exclude-libs 在 OS X 的 clang 上不可用

问题描述

我需要创建一个需要使用不同版本的 OpenSSL (BoringSSL) 的包装器库,原因在 [1] 的“包装器共享对象”中提供。

问题是--exclude-libs 在 OS X 的 clang 中不可用,因此我必须避免导出符号。

我有什么选项可以解决这个问题,例如在构建库后剥离符号?

[1] https://wiki.openssl.org/index.php/Android

标签: macosg++clangldclang++

解决方案


macOSld链接器允许您通过-hidden-l而不是-l. man ld这是Mac上的报价:

     -hidden-lx  This is the same as the -lx for locating a static library,
                 but treats all global symbols from the static library as if
                 they are visibility hidden.  Useful when building a dynamic
                 library that uses a static library but does not want to
                 export anything from that static library.

所以,不要-lssl在你的链接器标志中使用。使用-hidden-lssl.


推荐阅读