Important: Please read the Qt Code of Conduct -

[SOLVED]Where to add the lX11 reference to Qt project on linux

  • I'm writing a program to simulate keyboard events, but when i try to compile i get six "undefined reference to", after reading some articles i discovered that is a missing of a reference to lX11, but i don't understand exactly where to add this reference.

    @#include <QtCore/QCoreApplication>
    #include <X11/Xlib.h>
    #include <X11/keysym.h>
    #include <X11/extensions/XTest.h>

    int main(int argc, char *argv[])
    QCoreApplication a(argc, argv);

    Display *display = XOpenDisplay(NULL);
    unsigned int keycode;
    keycode = XKeysymToKeycode(display, XK_Pause);
    XTestFakeKeyEvent(display, keycode, True, 0);
    XTestFakeKeyEvent(display, keycode, False, 0);
    return a.exec(&#41;;


  • I found, add to .pro file: @LIBS += -lXtst -lX11@

Log in to reply