如何分发带有相关库的Mac OS X? [英] How to distribute a Mac OS X with dependent libraries?

查看:77
本文介绍了如何分发带有相关库的Mac OS X?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序(特别是 SO DevDays Countdown应用程序挑战的条目),它依赖于几个动态库,即libSDL,libSDL_ttf等.我已经通过MacPorts将这些库安装在/opt/local/lib下,并且很多人都没有安装这些库(有些人可能已经安装了这些库,但是不在该位置).

I have a program (specifically my entry for the SO DevDays Countdown app challenge) which relies on several dynamic libraries, namely libSDL, libSDL_ttf, and others. I have these libraries installed under /opt/local/lib via MacPorts, and many people won't have these installed (and some might have them installed, but not at that location).

如何分发程序,以便没有安装这些库的人可以立即运行它?显然,我必须分发各种.dylib文件,但是这样做是不够的.动态加载程序仍会在我安装它们的位置查找安装的库.有没有办法告诉动态加载器在可执行文件的当前目录中查找,就像Windows对DLL所做的那样?人们不必修改任何环境变量(例如DYLD_LIBRARY_PATH),因为我再次希望它可以即开即用地工作.

How do I distribute my program so that people without these libraries installed can run it out-of-the-box? Obviously I'll have to distribute the various .dylib files, but doing this is insufficient. The dynamic loader still looks for the libraries installed at the locations I have them installed at. Is there a way to tell the dynamic loader to look in the current directory of the executable, like what Windows does with DLLs? People shouldn't have to modify any environment variables (e.g. DYLD_LIBRARY_PATH), since again I want this to work out-of-the-box.

推荐答案

正如您所提到的,您没有使用Xcode,所以有点困难.以下是我偏好设置的选项:

As you mentioned you're not using Xcode, so it's a bit difficult. Here are options in my order of preference:

  1. 切换到Xcode.使用框架. SDL库已经可以作为框架使用了,我已经看到了不止几个商业游戏,它们在应用程序捆绑包中都带有libsdl.framework.

  1. Switch to Xcode. Use frameworks. The SDL libraries are available as frameworks already, and I've seen more than a couple commercial games with a libsdl.framework inside the app bundle.

使用框架,但保留Makefile.下载SDL库的框架版本(或自行构建),然后使用-framework链接器标志与它们链接.可以将框架与您的应用程序一起分发,也可以不与您的应用程序一起分发,并告诉您的用户将它们放在〜/Library/Frameworks或/Library/Frameworks中.我不会为此而烦恼安装程序.

Use frameworks, but keep your Makefiles. Download the framework versions of your SDL libraries (or build them yourself), and link with them with the -framework linker flag. Distribute the frameworks with your app or don't, and tell your users to put them in either ~/Library/Frameworks or in /Library/Frameworks. I wouldn't bother with an installer for this.

针对SDL的静态链接.在Makefile中,您必须列出静态库的路径,而不是使用-l标志,例如,运行"ld blah blah/opt/local/lib/libsdl.a".我没有办法告诉-l比共享库更喜欢静态,并且相信我,我已经看过了.

Statically link against SDL. In the Makefile, you'll have to list the path of the static libraries rather than use the -l flag, e.g., you run "ld blah blah /opt/local/lib/libsdl.a". There is no way that I know to tell -l to prefer static over shared libraries, and believe me, I've looked.

这篇关于如何分发带有相关库的Mac OS X?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆