码迷,mamicode.com
首页 > 其他好文 > 详细

Shared library

时间:2017-03-22 16:04:24      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:something   base   option   opera   run   str   tin   encode   where   

There are some differences between shared libraries on linux (*.so), windows (*.dll) and MacOS (*.dylib).

The shared libraries must be located in some folder where they can be found, either by the linker, or by the OS runtime.

It is possible to add the folders of the libraries to the system Path, or copy those shared libraries to some system folder, so they are found by the OS.

In Windows and OSX, the simplest approach is just to copy the shared libraries to the executable folder, so they are found by the executable, without having to modify the path.

In UNIX based operating systems like Linux and OSx, there is something called rpath (run-time search path) that is used to locate the shared libraries that another library or executable needs for execution.

The rpath is encoded inside dynamic libraries and executables and helps the linker to find its required shared libraries.

In linux rpath is just an option, which means that, if the linker doesn’t find the library in rpath, it will continue the search in system defaults paths (LD_LIBRARY_PATH... etc)

But in OSX with dylibs it doesn’t work like that. In OSX, if the linker detects that an rpath is invalid (the file does not exist there), it will fail. In OSX, libraries are built with the hard restriction of knowing (before installing them) where (in which folder) they will be installed.

 

Shared library

标签:something   base   option   opera   run   str   tin   encode   where   

原文地址:http://www.cnblogs.com/codingtao/p/6600334.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!