usb4java/libusb4java

Does not build with libusb 1.0.22

rekado opened this issue · 2 comments

The build fails with libusb 1.0.22 because libusb_set_debug is deprecated:

/tmp/guix-build-libusb4java-0-1.396d642a5.drv-0/source/src/SsEndpointCompanionDescriptor.c
/tmp/guix-build-libusb4java-0-1.396d642a5.drv-0/source/src/LibUsb.c: In function ‘Java_org_usb4java_LibUsb_setDebug’:
/tmp/guix-build-libusb4java-0-1.396d642a5.drv-0/source/src/LibUsb.c:133:5: error: ‘libusb_set_debug’ is deprecated: Use libusb_set_option instead [-Werror=deprecated-declarations]
     libusb_set_debug(ctx, level);
     ^
In file included from /tmp/guix-build-libusb4java-0-1.396d642a5.drv-0/source/src/usb4java.h:11:0,
                 from /tmp/guix-build-libusb4java-0-1.396d642a5.drv-0/source/src/LibUsb.c:19:
/gnu/store/j8hzc465xy33cjfcq3wv39szxia4xrzv-libusb-1.0.22/include/libusb-1.0/libusb.h:1300:18: note: declared here
 void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
                  ^

looks like different calls required depending on version of libusb being used:
libusb_set_debug(libusb_context *ctx, int level);
needs to change to
libusb_set_option(libusb_context, LIBUSB_OPTION_LOG_LEVEL, level);
wrapped in checks to
LIBUSB_API_VERSION and LIBUSBX_API_VERSION

This is fixed in usb4java 1.3.0 which now uses (and requires) libusb 1.0.22. The setDebug method now internally calls libusb_set_option so there is no more deprecation error on compile. But setDebug is now also marked as deprecated so you should use setOption() now.