Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Compilation issues on Linux



  • Hi,
    I have a strange issue on Linux if I tried to build an app including a event filter and which has X11 libraries included.
    Part of code:
    ui.channelsWidget->installEventFilter(this);
    bool MainWindow::eventFilter(QObject *object, QEvent event)
    {
    if (object == ui.channelsWidget && event->type() == QEvent::KeyPress)
    {
    QTreeWidgetItem
    item = ui.channelsWidget->currentItem();
    QKeyEvent *keyEvent = static_cast<QKeyEvent >(event);
    if (keyEvent->key() == Qt::Key_Right)
    {
    ui.channelsWidget->filterExpand(item);
    return true;
    }
    else
    return false;
    }
    return false;
    }
    void ChannelsTree::filterExpand(QTreeWidgetItem
    item)
    {
    if((item->type() & CHANNEL_TYPE) && !item->isExpanded())
    item->setExpanded(true);
    }

    When I build on Linux:
    mainwindow.cpp:6208:65: error: expected unqualified-id before numeric constant
    if (object == ui.channelsWidget && event->type() == QEvent::KeyPress)
    ^~~~~~~~
    mainwindow.cpp:6208:63: error: expected ‘)’ before numeric constant
    if (object == ui.channelsWidget && event->type() == QEvent::KeyPress)
    ~ ^
    X11 libraries are includes as follow:
    #include <QX11Info>
    #include <X11/Xlib.h>
    #include <X11/Xutil.h>
    I have no error on Windows.
    Have you an idea to fix it?
    Thanks.


  • Lifetime Qt Champion

    Don't include the x11 headers - or why do you need them?
    If you really need them then one of the names in the affected line is a define in the included x11 headers - undefine it

    mainwindow.cpp:6208

    6208 ? wtf...



  • @Oreonan said in Compilation issues on Linux:

    error: expected ‘)’ before numeric constant

    This is a pretty big class. Can you check if there is any line ending issue in your code?
    Display endings of all lines in your editor.
    https://superuser.com/questions/374028/how-are-n-and-r-handled-differently-on-linux-and-windows



  • Hi and thanks for your answers,
    I need this X11 libraries to use some specific functions on Linux.
    My file haven't any end line issue apparently.
    How can I find what make problem on X11 headers and undefine it?



  • I just moved my code to another file which not include X11 headers and it's working now.


Log in to reply