Mac OS X:通过添加函数来扩展共享库
我想通过添加函数来扩展 Mac OS X 上的共享 c 库 (dylib)。让我们调用函数 const char *get_string(void)
。我的方法如下:
我创建了一个包含 get_string(void)
函数的新共享库,并且喜欢它来对抗我想要扩展的库。可以说是一个库包装。到目前为止,一切都很好。下一步是将应用程序链接到我的新扩展库,但问题是扩展库仅导出符号 _get_string
而不是原始库的那些符号。这就是为什么链接“扩展”库(而不是原始库)会产生大量未解析的符号警告/错误。
有没有办法导出原始库的所有这些符号(有很多)或者是否有更好的方法来解决问题。基本上我只是想扩展现有的库。顺便说一句,我可以访问原始库的源代码,但我不能只是重新编译它。
提前致谢!
I would like to extend a shared c library (dylib) on Mac OS X by adding a function. Let's call the function const char *get_string(void)
. Here is my approach:
I created a new shared library containing the get_string(void)
function and liked it against the library I wanted to extend. A library wrapper so to speak. So far so good. The next step would be to link an application against my new extended library but the problem is that the extended library does only export the symbol _get_string
but not those symbols of the original library. That's why linking against the "extended" library (instead of the original library) produces a lot of unresolved symbol warnings/error.
Is there any way to export all those symbols of the original library (there are a lot) or is there a better approach to solve the problem. Basically I just want to extend an existing library. BTW I have access to the original library's source but I can't just recompile it.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ld 这个选项怎么样:
How about this option to ld: