如何在应用程序中使用dylib文件? [英] How to use dylib file in application?

查看:316
本文介绍了如何在应用程序中使用dylib文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了lib.dylib动态库.我想在我的应用程序中使用该库. 需要什么构建"设置和构建阶段"设置? 在Objective-C中使用库的步骤.

I have created lib.dylib dynamic library. I want to use that library in my application. What are the Build setting and build phase settings are required? Steps to use the library in objective-c.

推荐答案

所以有2种方法...

so there are 2 ways...

1)如果Dyld在链接时可用,则只需对其链接即可. (在Xcode中,将其添加到要构建的目标的链接构建阶段.)

1) if the Dyld is available at link time, then you just link against it. (in Xcode you add it to the link build phase of the target you are building.)

如果使用框架:标头将最终出现在标头搜索路径中,因此您可以#import <framework/header.h>它们.

if using a framework: The headers will end up in the header search path so you can #import <framework/header.h> them.

2)如果不是,那么您将需要使用dlopen打开动态库,然后直接读取每个函数……这更多的是一项特殊任务,例如处理插件建筑.

2) if it isn't then you will need to open the dynamic library with dlopen, then you read in each function directly... this is much more of a specialty task, like dealing with a plug-in architecture.

如果您提供动态库,则有些棘手的想法,那么库安装路径相对于可执行文件就存在问题...但是如果您点击它们,则只需要解决它们即可(以谷歌搜索)

there are some tricky thinks if you are supplying the dynamic lib then there are issues with the library install path being relative to the executable... but you will just have to tackle them if you hit them (start by googling @rpath)

这篇关于如何在应用程序中使用dylib文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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