将一些 macports 库与可执行文件打包以创建应用程序包

发布于 2024-12-29 01:32:15 字数 355 浏览 3 评论 0原文

我正在尝试为一个游戏创建一个应用程序包,该游戏使用我通过 macports 安装的一些库。我想将依赖项放入包中,但不知道如何做到这一点。

我已经编译了游戏并尝试使用 install_name_tool 更改所使用的路径,以便可执行文件在捆绑包内搜索,我没有收到错误,但路径没有改变。例如: install_name_tool -change libSDL-1.2.0.dylib @executable_path/../Frameworks/libSDL-1.2.0.dylibmeandmyshadow

该可执行文件是使用 CMake 生成的 Makefile 构建的。

XCode 会是更好的选择吗?我正在采取的步骤中是否遗漏了什么?

I'm trying to create an application bundle for a game that uses some libraries I installed using macports. I would like to put the dependencies inside the bundle but am at loss on how to do that.

I've compiled the game and tried to use install_name_tool to change the path used so that the executable searches inside the bundle, I get no error but the path doesn't change. E.g.:
install_name_tool -change libSDL-1.2.0.dylib @executable_path/../Frameworks/libSDL-1.2.0.dylib meandmyshadow

The executable was built using a CMake generated Makefile.

Would XCode be a better option? Is there anything I'm missing from the steps I'm taking?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

极致的悲 2025-01-05 01:32:15

要回答有关如何使用 install_name_tool 的具体问题:如果您使用 otool -L Meandmyshadow 查看meandmyshadow 的库链接,它可能看起来像这样:

meandmyshadow:
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
    /opt/local/lib/libSDL-1.2.0.dylib (compatibility version 12.0.0, current version 12.3.0)
    ...

当您使用install_name_tool更改程序中的引用,需要使用完整的引用。您指定要更改引用libSDL-1.2.0.dylib,但需要指定绝对路径,例如/opt/local/lib/libSDL-1.2.0.dylib

install_name_tool -change /opt/local/lib/libSDL-1.2.0.dylib @executable_path/../Frameworks/libSDL-1.2.0.dylib meandmyshadow

至于如何将库包含到应用程序包中的更大问题,您可以像上面使用 install_name_tool 那样手动完成,或者考虑尝试 dylibbundler 它会自动为您完成此操作。您可以使用 MacPorts 安装它:sudo port install dylibbundler

To answer your specific question about how to use install_name_tool: if you look at the library linkage of meandmyshadow using otool -L meandmyshadow it'll probably look something like this:

meandmyshadow:
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
    /opt/local/lib/libSDL-1.2.0.dylib (compatibility version 12.0.0, current version 12.3.0)
    ...

When you use install_name_tool to change a reference in the program, you need to use the complete reference. You specified that you wanted to change the reference libSDL-1.2.0.dylib but you need to specify the absolute path, e.g. /opt/local/lib/libSDL-1.2.0.dylib:

install_name_tool -change /opt/local/lib/libSDL-1.2.0.dylib @executable_path/../Frameworks/libSDL-1.2.0.dylib meandmyshadow

As for the bigger question about how to include libraries into an application bundle, you can do it manually as you're doing above with install_name_tool, or consider trying dylibbundler which does it for you automatically. You can install it using MacPorts: sudo port install dylibbundler.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文