Problems in using make – usb.h not found

homebrewlibrary

I am trying to use make to build a binary from a source code for a program I need.

Link to source: https://github.com/pali/0xFFFF

It requires usb.h, which seems to be part of usblib-compat. I installed the latter by brew install usblib-compat. But still usb.h can't be seen, although I know where it is (under /usr/local/Cellar/usblib-compat/version/include).

I read a lot over the Internet and tried to set many environment variables, but no success. Any idea?

UPDATE

After many trials, I have progressed somehow. Namely, the file config.mk is clearly read during the make'ing process, although I have to admit that it is not clear to me how this is done; anyway, I noticed two lines commented:

CPPFLAGS += -I/usr/local/include
LDFLAGS += -L/usr/local/lib -Wl,-R/usr/local/lib

I uncommented them and now something happens: the usb.h is found. I think the first of these variable definitions tells the compiler where to look tor header files, and the second tells the linker where to look for libraries – but again it is not completely clear to me.

In any case, I have still problems. Namely, the make'ing process outputs two warnings and an error, and then stops:

usb-device.c:90:57: warning: unused parameter 'udev' [-Wunused-parameter]
static void usb_reattach_kernel_driver(usb_dev_handle * udev, int interface) {
                                                        ^
usb-device.c:90:67: warning: unused parameter 'interface' [-Wunused-parameter]
static void usb_reattach_kernel_driver(usb_dev_handle * udev, int interface) {

usb-device.c:324:13: error: use of undeclared identifier 'RTLD_DEFAULT' if ( dlsym(RTLD_DEFAULT, "libusb_init") )

Seems this program is difficult to port from Linux to Mac, although I think it should be portable. If anyone has any idea about what to do (apart from running a Linux distribution…), it would be much appreciated.

Best Answer

You haven't told which program you want to compile, so it is impossible to give specific advice.

The general advice is to look at the program's README's, documentation and/or Makefile for ways to specify the include path.

For example you might edit the Makefile directly to identify where the include path is specified. In many projects the program is compiled by gcc/llvm and the include paths are specified using "-I" arguments to the compiler.

You could find that spot in the Makefile and add:

  -I/usr/local/Cellar/usblib-compat/version/include
Related Question