Important: Please read the Qt Code of Conduct -

Qt on Linux with X11 Link Errors

  • I'm trying to send Global [Root Window?] X11 Mouse events from Qt Widget application.
    Found some example code and moved it into my project.

    Headers look like this:

    #include <QMainWindow>
    #include <QDebug>
    #include <QString>
    #include <mouseclick.h>
    //#include <stdio.h>
    //#include <stdlib.h>
    //#include <string.h>
    #include <unistd.h>
    #include <X11/Xlib.h>
    #include <X11/Xutil.h>

    My Functions call XOpenDisplay, XQueryPointer, XSendEvent, XFlush.

    I've added this to Project file.
    QT += x11extras

    Compile works, but these link errors:

    /usr/bin/ld: mouseclick.o: undefined reference to symbol 'XFlush'
    //usr/lib/x86_64-linux-gnu/ error adding symbols: DSO missing from command line
    Makefile:298: recipe for target 'QtShowRunner' failed
    collect2: error: ld returned 1 exit status
    make: *** [QtShowRunner] Error 1
    09:11:49: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project QtShowRunner (kit: Desktop Qt 5.14.2 GCC 64bit)
    When executing step "Make"

    Commenting out XFlush just causes another XCall to show up this way, so apparently the XLibrary is not being included in link. Can't find an example page that shows how to fix the Project file.

    Is this the problem? and How do I fix it? Or is there another better way to send global Mouse Click events?

  • I added this to project, but it still does not work:
    alt text

    alt text

    Confirmed that is present at the specified path.

    Details here:

    How do I tell Qt where to find this library so the link will work?

  • Lifetime Qt Champion


    It's "-lX11"

  • @SGaist Super. And where does that go exactly?

  • Lifetime Qt Champion

    LIBS += -lX11

  • @SGaist Allllll rightyyyyyy thennnnnnnn
    Thanks very much.
    Just got a successful build. Now to see if it works.

  • Lifetime Qt Champion

    Good !

    Then please mark the thread as solved using the "Topic Tools" buttons si that other forum users may know a solution has been found :-)

  • @SGaist Thanks again. The code does not do the right thing yet. but it does compile and run.

Log in to reply