Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

  1. Copy libusb to your project.
  2. Add #include lines.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top