如何引用 dylib?
我有一个用独立于平台的 C++ 编写的应用程序,该应用程序主要在 Windows 上开发。我现在正尝试在 Mac 上启动并运行它,但我似乎不知道如何链接到我正在使用的第三方库的 Mac 版本。我将库的 include 和 lib 文件夹分别添加到标头和库搜索路径中,并进行编译/链接,但在运行时显示以下内容:
dyld: Library not returned: @executable_path/../Frameworks/libsfml-system-d .2.dylib 引用自:/Users/jdoe/Library/Developer/Xcode/DerivedData/Foobar-fonhiddwdwvgqygcegiffqkontxi/Build/Products/Debug/Foobar.app/Contents/MacOS/Foobar 原因:找不到图像
我可以通过将 dylibs 放入 /usr/lib 来让它运行,但我认为这对于分发来说不是一个好主意。如何将 dylib 包含在我的应用程序包中?
I have an application written in platform-independent C++ which has been primarily developed on Windows. I'm now trying to get it up and running on a Mac but I seem to be lost in how to link to the Mac version of a third-party library I'm using. I added the library's include and lib folders to header and library search paths respectively and it compiles/links but upon running dies with the following:
dyld: Library not loaded: @executable_path/../Frameworks/libsfml-system-d.2.dylib
Referenced from: /Users/jdoe/Library/Developer/Xcode/DerivedData/Foobar-fonhiddwdwvgqygcegiffqkontxi/Build/Products/Debug/Foobar.app/Contents/MacOS/Foobar
Reason: image not found
I can get it to run by putting the dylibs in /usr/lib but I don't think this is a good idea for distribution. How can I include the dylib inside my app bundle?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加复制文件构建阶段,将 dylib 复制到应用程序包内的 Frameworks 文件夹中。 (当您获取有关复制文件构建阶段的信息时,框架是目标选择之一。)
Add a copy-files build phase that copies the dylib into the Frameworks folder inside the app bundle. (When you Get Info on a copy files build phase, Frameworks is one of the destination choices.)