0

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.

  • 2
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Silvano Cerza Jun 24 '19 at 09:18

1 Answers1

1

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