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.
dlsym()
(on macOS Sierra 10.12.3), it says: Ifdlsym()
is called with the special handle RTLD_DEFAULT, then all mach-o images in the process (except those loaded withdlopen(xxx, RTLD_LOCAL)
) are searched in the order they were loaded. This can be a costly search and should be avoided. So, you should be getting the symbol defined if you include<dlfcn.h>
, unless you've managed to specify (directly or indirectly) a#define
that prevents the symbol from being specified.usb-device.c
I found the following:21 #ifndef _GNU_SOURCE 22 #define _GNU_SOURCE 23 #endif 24 25 #include <stdio.h> 26 #include <stdlib.h> 27 #include <stdint.h> 28 #include <string.h> 29 #include <errno.h> 30 #include <ctype.h> 31 #include <signal.h> 32 #include <dlfcn.h>
Sodlfcn.h
seems to be already included, and also_GNU_source
is defined, which should enable the definition ofRTLD_DEFAULT
.