How do I create shared library using ld?

☆樱花仙子☆ 提交于 2019-12-12 13:54:25

问题


I know how to create shared libraries using gcc and ln, but how do I create a shared library using only ld when I have object files (from c++ or c code) as input and how do I swap onto new version of library?


回答1:


how do I create a shared library using only ld when I have object files (from c++ or c code) as input

You could run gcc -v -shared ... to discover what options gcc passes to ld. You could then pass the same arguments to ld directly, and you should end up with identical result.

Note: this is ill-advised (don't do this): the arguments change with different versions of gcc and ld, and they change from one OS release to the next.

It is very common to construct link lines for ld that used to be correct some years ago, but no longer are. The bugs introduced when doing this are often low-level and subtle, and beyond most programmers' ability to understand and fix.



来源:https://stackoverflow.com/questions/36876689/how-do-i-create-shared-library-using-ld

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!