Objective-C 中的 C 代码(类/框架/库)
如何在 Objective-C 类中引用像 libusb 这样的类/框架/库?
目前,我尝试从 .h 文件中的 @interface 内的库启动枚举/结构函数。
但显然这不起作用。 :/
我已“安装”它(位于 /usr/local 中),并尝试添加文件和框架。但没有帮助。
How can I reference a class/framework/library like libusb in an Objective-C class?
Currently I have tried to initiate an enum/struct-function from the library inside my @interface in my .h-file.
But that doesn't work, apparently. :/
I have it "installed" (it's in /usr/local), and tried adding both the files and as framework. Doesn't help, though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能尚未将
/usr/local/include
和/usr/local/lib
添加到项目中的搜索路径中。在 Xcode 中,调出项目设置或目标设置,然后查找名为“搜索路径”的部分。双击“标题搜索路径”并添加/usr/local/include
。现在,双击“库搜索路径”并添加/usr/local/lib
。当您重建项目时,libusb 应该可用。您需要在使用该产品功能的每个源文件的顶部添加#include
。Apple 对库和框架进行了区分。图书馆就是您现在所拥有的。您可以编译和链接一些头文件和库 (dylib) 文件。它们存储在一些全局位置,例如
/usr/include
、/usr/local/include
等等。框架是包含标头、库、图形资源、版本信息等的捆绑包。Chances are that you haven't added
/usr/local/include
and/usr/local/lib
to the search paths in your project. In Xcode, bring up either the project settings or the target settings and look for a section named "Search Paths". Double-click on "Header Search Paths" and add/usr/local/include
. Now, double-click on "Library Search Paths" and add/usr/local/lib
. When you rebuild your project, libusb should be available. You will need to add#include <libusb.h>
at the top of each source file that uses functionality from that product.Apple makes a distinction between libraries and frameworks. A library is what you have now. There are header files and library (dylib) files that you compile and link against. They are stored in somewhat global locations, such as
/usr/include
,/usr/local/include
, and so-forth. Frameworks are bundles that contains headers, libraries, graphical resources, version information, and more.#include
行。#include
lines.