Joe*_*lav 7 linux hidden visibility symbols g++
我在Linux/Mac下编译了一个隐藏了符号的C++库.我已经为我的所有类使用_ attribute _((visibility("hidden")))并使用选项(-c -O2 -fPIC -MMD -MP -MF)进行编译.在Mac下,使用MacDependencies(http://code.google.com/p/macdependency/),工作完成得很好,因为我只看到我的导出(实际上我看到了之前和之后的差异).
但是,我注意到使用nm我仍然可以看到符号的所有名称.这在Mac和Linux下都会发生.
这是为什么?有什么方法可以避免这种情况吗?
最诚挚的问候和感谢,乔
Max*_*kin 13
公共或隐藏的符号仍然存在.nm显示所有符号.不同之处在于隐藏符号不可用于动态链接器,即不导出且不能插入.
您可能还喜欢以下内容 man gcc:
-fvisibility=default|internal|hidden|protected
...
A good explanation of the benefits offered by ensuring ELF symbols
have the correct visibility is given by "How To Write Shared
Libraries" by Ulrich Drepper (which can be found at
<http://people.redhat.com/~drepper/>)---however a superior solution
made possible by this option to marking things hidden when the
default is public is to make the default hidden and mark things
public. This is the norm with DLL's on Windows and with
-fvisibility=hidden and "__attribute__ ((visibility("default")))"
instead of "__declspec(dllexport)" you get almost identical
semantics with identical syntax. This is a great boon to those
working with cross-platform projects.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10318 次 |
| 最近记录: |