开发者

How do I prevent export of symbols from statically linked library?

I have created a shared library on linux x86. In creating it, I have statically linked in openssl. OpenSSL is only u开发者_如何转开发sed internally however I see that the openssl symbols have been exported. This is causing problems for other libraries that need my library AND openssl because the wrong symbol can be loaded at runtime. Is there a way to prevent all of the openssl symbols from getting exported when I statically link it into my shared library?

Thanks, Mike


Assuming you are using gcc, when linking your library, set -fvisibility=hidden and in your library source, mark all of the functions you want to be visible as extern. I think this should work as long as openssl has not declared their own functions extern.

I think if openssl has declared some symbols extern, you can manually force symbols to be hidden with pragmas.

There are other options involved. Check the gcc docs in the fvisibility section for a full explanation of what is available to you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜