1

I installed the hidapi library from Signall11 on my windows10 pc (using minGW). But now I'm having some trouble actually getting it to work with gcc. I have some main.c file in which I include the hidapi.h file. My gcc command looks like

gcc main.c

I'm not sure where I'm going wrong because whenever I try to run this command I get an undefined reference error to some function that is defined in the hidapi.h file.

Christian Gibbons
  • 4,272
  • 1
  • 16
  • 29

1 Answers1

0

A full compile command for a project using hidapi is like this:

gcc -o your_app your_app.c -lhidapi-hidraw

It's not enough to include #include "hidapi.h" in the C-code, which does let gcc compile. You also need -lhidapi-hidraw to link with the library. I.e. compiling is in fact a 2 step process.

jcoppens
  • 5,306
  • 6
  • 27
  • 47