Mac OSX中的@executable_path, @load_path和@rpath的理解

本文转载自:https://wincent.com/wiki/@executable_path,[email protected][email protected]。个人觉得写的很不错,简洁明了。

Absolute paths

Useful for frameworks installed in shared locations. Example:

  • Install path: /Library/Frameworks/Foo.framework/Versions/A/Foo

@executable_path

Useful for frameworks embedded inside applications, because it allows you to specify the location of the framework relative to the application‘s executable:

  • Install path: @executable_path/../Frameworks/Foo.framework/Versions/A/Foo
  • Application location: /Applications/Foo.app
  • Executable path: /Applications/Foo.app/Contents/MacOS
  • Framework location: /Applications/Foo.app/Contents/Frameworks/Foo.framework
  • Linker puts all this together to figure out that the framework binary can be found at:/Applications/Foo.app/Contents/MacOS/../Frameworks/Foo.framework/Versions/A/Foo

@loader_path

Available from Mac OS X 10.4 Tiger onwards; useful for frameworks embedded inside plug-ins, because it allows you to specify the location of the framework relative to the plug-in‘s code (remember, plug-ins may not actually know where they are going to be installed, relative to the application, so knowing @executable_path doesn‘t help us in this case):

  • Install path: @loader_path/../Frameworks/Foo.framework/Versions/A/Foo
  • Application location: /Applications/Foo.app
  • Plug-in location: /Library/Application Support/Foo/Plug-Ins/Bar.bundle
  • Executable path: /Applications/Foo.app/Contents/MacOS
  • Loader path: /Library/Application Support/Foo/Plug-Ins/Bar.bundle/Contents/MacOS
  • Framework location: /Library/Application Support/Foo/Plug-Ins/Bar.bundle/Contents/Frameworks/Foo.framework
  • Linker puts all this together to figure out that the framework binary can be found at:/Library/Application Support/Foo/Plug-Ins/Bar.bundle/Contents/MacOS/../Frameworks/Foo.framework/Versions/A/Foo

Note that if the "loader" is an application rather than a plug-in, the @loader_path ends up being equivalent to @executable_path.

@rpath

New in Mac OS X 10.5 Leopard is @rpath. Key points:

  • @rpath instructs the dynamic linker to search a list of paths in order to locate the framework
  • critically, this list is embedded in the loading application
  • this means that a single framework with @rpath/Foo.framework/Versions/A/Foo can be made to work in a number of different ways; that is, you are effectively no longer limited by the choice of specifying your "install path" using either @executable_path or @loader_path
  • the down side: you now have to pass additional linker flags when building the host application (eg. -rpath @executable_path/../Frameworks or/Library/Frameworks; note that specifying both will cause the dynamic linker to try looking in both locations)

Sources

时间: 2024-10-06 20:32:39

Mac OSX中的@executable_path, @load_path和@rpath的理解的相关文章

MAC OSX 中解决编译“'cc' failed with exit status 1”错误 和clang: error: unknown argument 错误

错误例子: error: command 'cc' failed with exit status 1 clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future] clang: note: this will be a hard error (cannot be downgraded to a warning) in the fu

Mac osx中如何开启代码高亮

IM (Wikipedia图) Vim 是一款相当给力的源自UNIX平台的命令行文本编辑器,不过不给力的是,Mac OS X下并没有诸多Linux发行版上VIM那些牛逼哄哄的神马代码高亮显示啊,自动缩进啊神马的. (译者注:通常Linux发行版可以通过编辑/etc/vimrc文件更改全局VIM设定或者针对某个用户的~/.vimrc进行个性化配置) 为了弥补这个缺憾,请按如下方法操作: 打开Terminal,输入如下命令: cd /usr/share/vim sudo vim vimrc 两行命令

在Mac OSX中获取网卡MAC地址

今天在CocoaChina上看到有人发帖在询问如何在Mac OSX下获得网卡的物理地址,恰好最近在学习IOKit的一些知识,所以通过IOKit的接口肯定是可以很方便的拿到MAC地址信息的,但不知道还有没有其它更方便的API了,所以我姑且贴出一段通过IOKit去获得网卡MAC地址的代码: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 - (void)applicationDid

[Java Web]Mac OSX中MyEclipse的Console输出乱码的问题

一.问题说明 MAC系统,Myeclipse10那版(你懂的) 用Myeclipse自带的Tomcat6去在本机部署调试时,控制台中文乱码 之前采用新建Tomcat 7(系统Tomcat)暂时解决了,但是一直不明白为什么. 二.问题解决 说来说去,肯定是编码的问题,但是到底哪里加编码就是问题核心所在了 我无意中对比了下新建的Tomcat 7 server和自带的 Tomcat6,发现区别就在这里 看下对比 三.知识点 3.1 Mac下Myeclipse控制台中文乱码解决 版权声明:本文为博主原创

mac osx中 如何实现在sublime中 装载对c/c++ 自动排版插件astyleformatter

1. astyleformatter自动排版插件下载 在如下网址中,找到download(如图),然后转接到github下载插件.(可能需要FQ) 网址:https://packagecontrol.io/packages/SublimeAStyleFormatter 2.安装插件 (1)直接下载好想要的插件,然后打开菜单栏里的“Preferences”--->"Browse Packages",打开包的位置 (2)然后将下载的好插件直接放置到Packages目录,重启Subli

XE6移动开发环境搭建之IOS篇(6):安装XE6的PAServer到Mac OSX 10.8中(有图有真相)

网上能找到的关于Delphi XE系列的移动开发环境的相关文章甚少,本文尽量以详细的内容.傻瓜式的表达来告诉你想要的答案. 在安装PAServer前,我们先配置一下MAC的IP,以便我们的XE6能更好地连接它!--------------------------------------------------------------- 1.打开虚拟机,在MAC里,点一下桌面(星空图随便某个地方),在Finder中选择'前往','应用程序'. 2.在应用程序窗口里双击'系统偏好设置'. 3.双击'

XE6移动开发环境搭建之IOS篇(5):解决Windows和虚拟机下Mac OSX的共享问题(有图有真相)

XE6移动开发环境搭建之IOS篇(5):解决Windows和虚拟机下Mac OSX的共享问题(有图有真相) 2014-08-20 20:28 网上能找到的关于Delphi XE系列的移动开发环境的相关文章甚少,本文尽量以详细的内容.傻瓜式的表达来告诉你想要的答案. 在安装XE6 PAServer前,我们先解决Windows和虚拟机下Mac的文件共享问题,由于虚拟机和我们安装的XE6是同一台电脑,所以此问题很好解决.网上相传有很多的共享大法,但是在WIN7这种权限管制得过份的系统下显得相对复杂了,

在Mac OSX上运行Windows应用程序

在Mac OSX中,借助wine,不需要安装虚拟机也可以运行Window应用程序. wine是一个在Linux和UNIX之上的,WIndows3.x和Windows APIs的实现.是运用API转换技术实现出Linux对应到Windows相应的函数来调用DLL以运行Windows程序.Wine可以工作在绝大多数的UNIX版本下,包括Linux, FreeBSD和Solaris.另外,也有适用于Mac OSX的Wine程序. 注意,wine并非是一个模拟器. 官网:https://www.wine

mac osx 上面部署Django项目 apache+mysql+mod_wsgi

1.安装Xcode command line tools 首先,编译mysql和Homebrew需要用到Xcode command line tools,所以首先安装command line tools: 如果安装了Xcode,只需要“Preferences… > Downloads”,之后点击Command Line Tools安装按钮: 如果没有Xcode,去https://developer.apple.com/downloads,搜索Command Line Tools 下载安装 2.安