Home > Software engineering >  C libraries using QT
C libraries using QT

Time:03-23

I need to use functions from capability.h library inside my QT project. So I've successfully included <sys/capability.h> in my cpp file and tried this:

char *result = NULL;
ssize_t length;
cap_t caps;
path = "/*path/*";

caps = cap_get_file(path);
if (caps)
   result = cap_to_text(caps, &length);
else
   qDebug() << "ERROR";

cap_free(caps);

Now I have problems like "undefined reference to cap_get_file" with cap_get_file, cap_to_text and cap_free functions. What am I doing wrong and how should I use linux system libraries in QT?

CodePudding user response:

Add this line to your .pro file:

LIBS  = -lcap

It should do the trick.

  • Related