Search code examples
clinuxubuntumodulecompilation

Problem with Makefile compilation on Ubuntu, -lhidapi-libusb library


I have a slight problem with a Linux module compilation. No matter where I put a -lhidapi-libusb library reference in the make command, the module just refuses to compile. I know I'm doing something wrong, please help me, if you have some time.

Thanks

obj-m += light.o
all:
make -lhidapi -libusb -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules 
clean:
make -lhidapi -libusb -C /lib/modules/$(shell uname -r)/build M=$(PWD)

Output:

fatal error: hidapi/hidapi.h: No such file or directory
 #include <hidapi/hidapi.h>

Solution

  • What you're trying to do doesn't make sense, and will not work.

    libusb and HIDAPI are userspace libraries. They cannot be used within a kernel module.