Search code examples
linuxnode.jscompilationubuntu-14.04hidapi

Compiling hidapi with libusb instead of hidraw


I am trying to compile hidapi on ubuntu 14.04 for use with node-hid. Node-hid cannot see any devices for some reason when hidapi uses hidraw as this issue describes. The fourth post also offers a solution:

So, with my limited gcc/waf knowledge I managed to get it to build (I changed wscript to use ../hidapi/libusb/hid.c vs using /hidapi/linux/hid.c. I also changed its linkflags to use -lusb1.0 instead of -ludev and I added /usr/include/libusb-1.0 (a hardcoded path as the makefile wants to use pkgconfig to find that path.. I don't know an equivalent).

I have managed to change /hidapi/linux/hid.c to ../hidapi/libusb/hid.c in the wscript file and I also found the linkflags and changed them; but, I am not sure how to implement the last part about hardcoding the path. Where would I write this path? Or perhaps, is there a better way to get node-hid working?


Solution

  • node-hid doesn't use the wscript anymore, it has a binding.gyp now and so node-gyp is used instead. Also by default the binding.gyp uses libusb instead of hidraw, so this shouldn't be a problem.