How to use libsensors in QT application?

392 Views Asked by At

I am trying to make a simple CPU temp program in QT for Linux, but I cannot get libsensors to work with my project. As soon as I include the sensors/sensors.h and try to call int err = sensors_init(NULL); the compiler throws an error undefined reference to 'sensors_init'. I believe this is a linking issue, but I cannot solve it.

Edit:

I can fix the problem if I manually compile outside of QT creator with g++ -o main main.cpp -lsensors.

Now my question is how do I pass the -lsensors parameter to the g++ compiler in the QT creator. I am using qmake.

1

There are 1 best solutions below

0
Domen Jesenovec On BEST ANSWER

The solution is to add QMAKE_LIBDIR_FLAGS += -lsensors to the .pro file.