如何在Mac OS X上设置libusb ?

时间:2022-05-06 07:15:11

I'd like to try to make a user-space device driver using libusb on Mac, but I'm confused where to start. 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.

我想尝试在Mac上使用libusb制作一个用户空间设备驱动程序,但是我不知道从哪里开始。在SDK安装程序(我从http://www.ellert.se/twain-sane得到)中,它给出了一些我在电脑上找不到的例子。

Could anyone please describe how do I set up libusb for development on OS X? May I use Xcode? What should I include in my code?

请问如何在OS X上建立libusb进行开发?我可以用Xcode吗?在我的代码中应该包括什么?

Thank you!

谢谢你!

3 个解决方案

#1


14  

I tried to install the SDK from the aforementioned website and couldn't find a trace of it once the installer finished. 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.

我尝试从上述网站安装SDK,安装完成后找不到它的踪迹。虽然我在/usr/local/Developer/SDKs/MacOSX10.6找到了一些libusb项目。sdk/usr/local/我不确定它来自那个安装程序,因为我找不到任何例子,只有库,它们被标记为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,因为它至少把所有东西都放在一个已知的位置:

  • /opt/local/var/macports/software for install files
  • / opt /地方/ var / macports /软件安装文件
  • /opt/local/lib for libraries
  • / opt /地方/ lib库
  • /opt/local/include for header files
  • / opt /地方/包括头文件

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

sudo端口安装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. 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.

我没有太多使用Xcode的经验,因此我无法在这条道路上帮助您。就我个人而言,到目前为止我所做的是使用一个名为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. 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. 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).

更新:在macports安装目录中查找libusb,我没有发现任何包含的示例,这是一个很糟糕的例子。如果您已经了解了这一点,那么我建议您直接访问libusb的源代码,下载并解压tar文件,并构建示例目录中的代码。不好意思,我得到了libusb示例的迂回方式,但是我真的很欣赏macports对安装施加的组织,它为我省去了将来的一些麻烦(比如当我想卸载时)。

#2


52  

brew install libusb-compat 

Working on OSX Yosemite 10.10

在OSX优胜美地工作10.10

#3


5  

Easiest way to do this:

最简单的方法是:

brew install libusb

Homebrew is amazing and I recommend it for all developers that use Mac.

Homebrew是非常棒的,我向所有使用Mac的开发者推荐它。

#1


14  

I tried to install the SDK from the aforementioned website and couldn't find a trace of it once the installer finished. 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.

我尝试从上述网站安装SDK,安装完成后找不到它的踪迹。虽然我在/usr/local/Developer/SDKs/MacOSX10.6找到了一些libusb项目。sdk/usr/local/我不确定它来自那个安装程序,因为我找不到任何例子,只有库,它们被标记为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,因为它至少把所有东西都放在一个已知的位置:

  • /opt/local/var/macports/software for install files
  • / opt /地方/ var / macports /软件安装文件
  • /opt/local/lib for libraries
  • / opt /地方/ lib库
  • /opt/local/include for header files
  • / opt /地方/包括头文件

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

sudo端口安装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. 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.

我没有太多使用Xcode的经验,因此我无法在这条道路上帮助您。就我个人而言,到目前为止我所做的是使用一个名为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. 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. 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).

更新:在macports安装目录中查找libusb,我没有发现任何包含的示例,这是一个很糟糕的例子。如果您已经了解了这一点,那么我建议您直接访问libusb的源代码,下载并解压tar文件,并构建示例目录中的代码。不好意思,我得到了libusb示例的迂回方式,但是我真的很欣赏macports对安装施加的组织,它为我省去了将来的一些麻烦(比如当我想卸载时)。

#2


52  

brew install libusb-compat 

Working on OSX Yosemite 10.10

在OSX优胜美地工作10.10

#3


5  

Easiest way to do this:

最简单的方法是:

brew install libusb

Homebrew is amazing and I recommend it for all developers that use Mac.

Homebrew是非常棒的,我向所有使用Mac的开发者推荐它。