I have a single main.cpp
file with this content:
#include <iostream>
#include <hidapi/hidapi.h>
#define MAX_STR 255
using namespace std;
int main (void) {
int res;
unsigned char buf[65];
wchar_t wstr[MAX_STR];
hid_device *handle;
int i;
cout << "Hello\n";
res = hid_init();
handle = hid_open(0xC251, 0x2201, NULL);
return 0;
}
where hidapi
was installed following the instructions for Ubuntu 20.04, i.e. sudo apt install libhidapi-dev
. Now I want to compile this with
g++ main.cpp -o main
but I get main.cpp:(.text+0x32): undefined reference to `hid_init'
. How am I supposed to make this work? (Note that I had to write #include <hidapi/hidapi.h>
instead of #include <hidapi.h>
because otherwise it would complain about this also, not sure if this is related with the current issue.)