Arlene Fu
Arlene Fu

Reputation: 21

Device input event using libevdev in C++

I am trying to get the touch event from Raspberry Pi Touchscreen. I made it work using FT5406 driver in python and evtest in C. However, I want to write code for this in C++. I notice libevdev is very useful in C, but when I call it in C++, like

#include <libevdev/libevdev.h>

it will always give me

Fatal error: libevdev/libevdev.h: No such file or directory

I manually install libevdev and save it under the path of my code and provide complete path of that library, but the same thing happens.

I also try the method according to link, the problem is still here.

I already installed the corresponding package:

sudo apt-get install libevdev-dev
sudo apt-get install libudev-dev

Is anyone can help me out???

Upvotes: 2

Views: 4102

Answers (2)

Deanie
Deanie

Reputation: 2393

Just had this same problem. Just find the proper path to the header file.

sudo find / -name libevdev.h

Then include the path starting from the include directory. Mine was:

/usr/include/libevdev-1.0/libevdev/libevdev.h

So my include line was:

#include <libevdev-1.0/libevdev/libevdev.h>

Upvotes: 2

fluxrider
fluxrider

Reputation: 341

It all depends how you setup your include search paths, as using #include <my_file> won't search the current directory. You'd have to use #include "my_file" for that.

Anyway, don't bother copying to you current directory, simply supply the correct paths.

gcc my_code.c $(pkg-config --cflags --libs libevdev)

Where pkg-config will expand to something like -I/usr/include/libevdev-1.0/ -levdev, where libev-dev-1.0 has a subfolder libevdev.

Upvotes: 0

Related Questions