[英]How to set up libusb on Mac OS X?
I'd like to try to make a user-space device driver using libusb on Mac, but I'm confused where to start.我想尝试在 Mac 上使用 libusb 制作用户空间设备驱动程序,但我不知道从哪里开始。 In the SDK installer (which I got from http://www.ellert.se/twain-sane ) it said something about examples which I couldn't find anywhere on my computer.
在 SDK 安装程序(我从http://www.ellert.se/twain-sane获得)中,它说了一些我在我的电脑上找不到的例子。
Could anyone please describe how do I set up libusb for development on OS X?谁能描述一下如何在 OS X 上设置 libusb 进行开发? May I use Xcode?
我可以使用 Xcode 吗? What should I include in my code?
我应该在我的代码中包含什么?
brew install libusb-compat
在OSX Yosemite 10.10上工作
I tried to install the SDK from the aforementioned website and couldn't find a trace of it once the installer finished. 我尝试从上述网站安装SDK,并在安装程序完成后找不到它的痕迹。 Though I did find some libusb items at /usr/local/Developer/SDKs/MacOSX10.6.sdk/usr/local/ I'm not sure it came from that installer as I couldn't find any examples, just libraries and they were labeled as libusb0.1.4.
虽然我确实在/usr/local/Developer/SDKs/MacOSX10.6.sdk/usr/local/找到了一些libusb项目,但我不确定它来自那个安装程序,因为我找不到任何示例,只是库和它们被标记为libusb0.1.4。
On the other hand, since you asked your question with the macports tag, I'd suggest you use that to install libusb as it at least puts everything in a known location: 另一方面,既然你用macports标签问了你的问题,我建议你用它来安装libusb,因为它至少把所有东西都放在一个已知的位置:
If you've never used macports then once you have macports installed then you can install libusb using 如果你一旦你以前从未使用过的MacPorts然后使用MacPorts安装后,即可安装使用的libusb
sudo port install libusb
to install libusb1.0 or 安装libusb1.0或
sudo port install libusb-legacy
to install libusb0.1.12. 安装libusb0.1.12。
Then you can create a project in Xcode and link to the libusb-*.a library contained in /opt/local/lib (in my directory my library file is called libusb-1.0.a since I have libusb1.0 installed). 然后你可以在Xcode中创建一个项目并链接到libusb - *。/ opt / local / lib中包含的库(在我的目录中,我的库文件名为libusb-1.0.a,因为我安装了libusb1.0)。
I don't have much experience using Xcode so I can't help you any further down this path. 我没有太多使用Xcode的经验,所以我无法帮助你走这条路。 Personally what I've done so far is use a Python wrapper called pyusb to do some quick experimentation with libusb as I don't have to do IDE setup or library/include file setup with Python.
我个人到目前为止所做的是使用一个名为pyusb的Python包装器来对libusb进行一些快速实验,因为我不需要使用Python进行IDE设置或库/包含文件设置。
UPDATE: Poking around the macports install directory for libusb, I didn't find any examples included which was a bummer. 更新:在libusb的macports安装目录周围,我没有找到任何包含哪些例子,这是一个无赖。 If you've gotten this far then I'd suggest going directly to the source for libusb , download and unpack the tar file, and building the code that's in the example directory.
如果你已经做到这一点,那么我建议直接访问libusb的源代码,下载并解压缩tar文件,并构建示例目录中的代码。 Sorry for the roundabout way of getting libusb examples but I've really come to appreciate the organization macports imposes on installations which saves me quite a bit of future pain (like when I want to uninstall).
很抱歉获得libusb示例的迂回方式,但我真的很欣赏组织macports对安装的强加,这为我节省了很多未来的痛苦(比如当我想卸载时)。
once libusb is installed using following command:使用以下命令安装 libusb 后:
brew install libusb
or要么
brew install libusb-compat
link libusb to the build system using将 libusb 链接到构建系统使用
brew link libusb
to be able to configure any project depending on libusb, use pkg-config:要能够根据 libusb 配置任何项目,请使用 pkg-config:
pkg-config --cflags libusb-1.0
and和
pkg-config --libs libusb-1.0
before calling any ./configure
在调用任何
./configure
之前
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.