Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Xlib.h include problem
Qt 6.12 LTS is out! See what's new in the release blog

Xlib.h include problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 2.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mrdebugM Offline
    mrdebugM Offline
    mrdebug
    wrote on last edited by
    #1

    Hi, I'm writing a simple app that sends keystrokes to the active forms under X11.
    I need to use the header "Xlib.h".
    After adding the header in my .h file I have this compile error:

    In file included from /usr/include/X11/Xlib.h:44:0,
                     from ../PianoJoke/qfmainwindow.h:11,
                     from ../PianoJoke/main.cpp:1:
    /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtCore/qcoreevent.h:63:9: error: expected identifier before numeric constant
             None = 0,                               // invalid event
             ^
    /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtCore/qcoreevent.h:63:9: error: expected ‘}’ before numeric constant
    /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtCore/qcoreevent.h:63:9: error: expected unqualified-id before numeric constant
    In file included from /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtGui/qwindowdefs.h:44:0,
                     from /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtWidgets/qwidget.h:44,
                     from /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtWidgets/qmainwindow.h:44,
                     from /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtWidgets/QMainWindow:1,
                     from ../PianoJoke/qfmainwindow.h:4,
                     from ../PianoJoke/main.cpp:1:
    /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtCore/qobjectdefs.h:122:5: error: ‘friend’ used outside of class
         friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) Q_DECL_NOEXCEPT { return &staticMetaObject; } \
         ^
    /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtCore/qobjectdefs.h:124:30: note: in expansion of macro ‘Q_ENUM_IMPL’
     #define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x)
    

    What can I do in order to use the Xlib.h header in a Qt app?

    Need programmers to hire?
    www.labcsp.com
    www.denisgottardello.it
    GMT+1
    Skype: mrdebug

    jsulmJ 1 Reply Last reply
    0
    • mrdebugM mrdebug

      Hi, I'm writing a simple app that sends keystrokes to the active forms under X11.
      I need to use the header "Xlib.h".
      After adding the header in my .h file I have this compile error:

      In file included from /usr/include/X11/Xlib.h:44:0,
                       from ../PianoJoke/qfmainwindow.h:11,
                       from ../PianoJoke/main.cpp:1:
      /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtCore/qcoreevent.h:63:9: error: expected identifier before numeric constant
               None = 0,                               // invalid event
               ^
      /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtCore/qcoreevent.h:63:9: error: expected ‘}’ before numeric constant
      /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtCore/qcoreevent.h:63:9: error: expected unqualified-id before numeric constant
      In file included from /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtGui/qwindowdefs.h:44:0,
                       from /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtWidgets/qwidget.h:44,
                       from /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtWidgets/qmainwindow.h:44,
                       from /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtWidgets/QMainWindow:1,
                       from ../PianoJoke/qfmainwindow.h:4,
                       from ../PianoJoke/main.cpp:1:
      /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtCore/qobjectdefs.h:122:5: error: ‘friend’ used outside of class
           friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) Q_DECL_NOEXCEPT { return &staticMetaObject; } \
           ^
      /Dati/Qt/Qt5.11.1/5.11.1/gcc_64/include/QtCore/qobjectdefs.h:124:30: note: in expansion of macro ‘Q_ENUM_IMPL’
       #define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x)
      

      What can I do in order to use the Xlib.h header in a Qt app?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @mrdebug said in Xlib.h include problem:

      qfmainwindow.h

      Can you show its content?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • mrdebugM Offline
        mrdebugM Offline
        mrdebug
        wrote on last edited by
        #3

        It is completely empty. The behaviour occurs just adding "#include <X11/Xlib.h>" to an empty Qt project.

        #ifndef QFMAINWINDOW_H
        #define QFMAINWINDOW_H
        
        #include <QMainWindow>
        #include <X11/Xlib.h>
        
        namespace Ui {
        class QFMainWindow;
        }
        
        class QFMainWindow : public QMainWindow
        {
            Q_OBJECT
        
        public:
            explicit QFMainWindow(QWidget *parent = 0);
            ~QFMainWindow();
        
        private:
            Ui::QFMainWindow *ui;
        };
        
        

        Need programmers to hire?
        www.labcsp.com
        www.denisgottardello.it
        GMT+1
        Skype: mrdebug

        jsulmJ 1 Reply Last reply
        0
        • mrdebugM mrdebug

          It is completely empty. The behaviour occurs just adding "#include <X11/Xlib.h>" to an empty Qt project.

          #ifndef QFMAINWINDOW_H
          #define QFMAINWINDOW_H
          
          #include <QMainWindow>
          #include <X11/Xlib.h>
          
          namespace Ui {
          class QFMainWindow;
          }
          
          class QFMainWindow : public QMainWindow
          {
              Q_OBJECT
          
          public:
              explicit QFMainWindow(QWidget *parent = 0);
              ~QFMainWindow();
          
          private:
              Ui::QFMainWindow *ui;
          };
          
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @mrdebug Can you try

          extern "C"
          {
            #include <X11/Xlib.h>
          }
          

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

            You can also try to include Xlib.h before your Qt includes.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • mrdebugM Offline
              mrdebugM Offline
              mrdebug
              wrote on last edited by
              #6

              Solved by creating an external library that encapsulate the x11 layer.

              Need programmers to hire?
              www.labcsp.com
              www.denisgottardello.it
              GMT+1
              Skype: mrdebug

              I 1 Reply Last reply
              3
              • mrdebugM mrdebug

                Solved by creating an external library that encapsulate the x11 layer.

                I Offline
                I Offline
                Ines
                wrote on last edited by
                #7

                @mrdebug can you explain me how you created the library and where is allocated?

                1 Reply Last reply
                0
                • mrdebugM Offline
                  mrdebugM Offline
                  mrdebug
                  wrote on last edited by
                  #8

                  Have you never written and used a library?
                  It is the same.
                  Which is your doubt exactly?

                  Need programmers to hire?
                  www.labcsp.com
                  www.denisgottardello.it
                  GMT+1
                  Skype: mrdebug

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt
                  • Unsolved