Objective-C 中的 C 代码(类/框架/库)

发布于 2024-09-06 06:10:38 字数 222 浏览 9 评论 0原文

如何在 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 技术交流群。

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

发布评论

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

评论(2

拍不死你 2024-09-13 06:10:38

您可能尚未将 /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.

拥抱没勇气 2024-09-13 06:10:38
  1. 将 libusb 复制到您的项目中。
  2. 添加 #include 行。
  1. Copy libusb to your project.
  2. Add #include lines.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文