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

GCC Desktop Kit yellow mark on Linux



  • Hi,

    Just installed Linux and about to use Qt on it, but I have this problem:

    Screenshot from 2020-05-11 13-55-50.png

    How fix ix this please?


  • Lifetime Qt Champion

    @qcoderpro Take a look at https://doc.qt.io/qt-5/linux.html and install libgl1-mesa-dev package as shown there


  • Lifetime Qt Champion

    Hi,

    If you hover your cursor above the yellow mark you will have the information about what is going on.



  • @SGaist

    yes, but how to add a C++ compiler to it, please?

    Screenshot from 2020-05-11 14-03-13.png


  • Lifetime Qt Champion

    What Linux distribution are you using ?



  • @SGaist

    Ubuntu 20.04 LTS


  • Lifetime Qt Champion

    Then install the "build-essential" package.



  • @SGaist

    Is it a package I can install by Terminal?


  • Lifetime Qt Champion

    You know that if you have just search either in your terminal or whatever GUI Ubuntu provides for package management you would already have the installation running ?



  • @SGaist

    I installed it, thanks.

    What changes are needed to be made when we want to open a Qt project on Linux that we have already created and built using Windows?


  • Lifetime Qt Champion

    Well, unless you used Windows specific APIs, nothing. If you used external libraries, you'll have to use scopes to properly handle paths to them.



  • @SGaist

    I don't know "Windows specific APIs" unfortunately. Is there a list of them to see please?

    Here's my project on Windows:

    "DialogTest. pro"

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    CONFIG += c++11
    
    # The following define makes your compiler emit warnings if you use
    # any Qt feature that has been marked deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
        main.cpp \
        dialogtest.cpp
    
    HEADERS += \
        dialogtest.h
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    

    The heaser:

    #ifndef DIALOGTEST_H
    #define DIALOGTEST_H
    
    #include <QDialog>
    
    class QPushButton;
    class QComboBox;
    class QVBoxLayout;
    class QHBoxLayout;
    class QLabel;
    
    class DialogTest : public QDialog
    {
        Q_OBJECT
    
    public:
        DialogTest(QWidget *parent = nullptr);
    
    private slots:
        void itemChanged(int);
        void saveBtnClicked();
        void init();
        void load();
    
    private:
        QComboBox* cboBox = nullptr;
    
        QHBoxLayout* topHLayout = nullptr;
        QHBoxLayout* middleHLayout = nullptr;
        QHBoxLayout* bottomHLayout = nullptr;
        QVBoxLayout* mainLayout = nullptr;
    
        QLabel* select = nullptr;
        QLabel* ItemSelected = nullptr;
        QPushButton* save = nullptr;
    };
    #endif // DIALOGTEST_H
    

    The C++ file:

    #include "DialogTest.h"
    #include <QPushButton>
    #include <QComboBox>
    #include <QHBoxLayout>
    #include <QVBoxLayout>
    #include <QMessageBox>
    #include <QSettings>
    #include <QLabel>
    #include <QDebug>
    
    DialogTest::DialogTest(QWidget *parent)
        : QDialog(parent)
    {
        select = new QLabel(tr("Select an Item"));
        cboBox = new QComboBox;
        ItemSelected = new QLabel(tr("Selected Item"));
        save = new QPushButton(tr("&Save"));
    
        topHLayout = new QHBoxLayout;
        topHLayout->addWidget(select);
        topHLayout->addWidget(cboBox);
    
        middleHLayout = new QHBoxLayout;
        middleHLayout->addWidget(ItemSelected);
        middleHLayout->addStretch();
    
        bottomHLayout = new QHBoxLayout;
        bottomHLayout->addStretch();
        bottomHLayout->addWidget(save);
    
        mainLayout = new QVBoxLayout;
        mainLayout->addLayout(topHLayout);
        mainLayout->addLayout(middleHLayout);
        mainLayout->addLayout(bottomHLayout);
    
        setLayout(mainLayout);
    
        init();
        load();
    
        connect(cboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(itemChanged(int)));
        connect(save, &QPushButton::clicked, this, &DialogTest::saveBtnClicked);
    }
    
    void DialogTest::itemChanged(int index)
    {
      ItemSelected->setText(QString::number(index) + " = " + cboBox->currentText());
    }
    
    void DialogTest::saveBtnClicked()
    {
       QSettings settings("MySoft", "Star Runner");
       settings.setValue("settings", cboBox->currentIndex());
       QMessageBox::information(this, "Save", "Your item is saved, Please re-open the application");
    }
    
    void DialogTest::init()
    {
        cboBox->clear();
    
        for (int i=0; i<10; i++)
            cboBox->addItem("Item number " + QString::number(i));
    }
    
    void DialogTest::load()
    {
       QSettings settings("MySoft", "Star Runner");
       QVariant value = settings.value("settings",0);
    
       bool ok;
       int index = value.toInt(&ok);
    
       if(!ok)
       {
           QMessageBox::critical(this, "Error", "Error in loading the file");
           return;
       }
    
       if(index < cboBox->count())
        cboBox->setCurrentIndex(index);
    
       else
        cboBox->setCurrentIndex(0);
    }
    

    And on the Linux machine, lost of errors turned up:

    Screenshot from 2020-05-11 14-30-25.png


  • Lifetime Qt Champion

    That's strange, I would nuke the build folder and re-build from scratch.



  • @SGaist

    I did, although I'm not an expert on military tasks!
    Now there is only the project's directory on Desktop including 4 files: DialogTest.cpp, DialogTest.h, DialogTest .pro and main.cpp.

    I open the .pro file by the IDE and configure the project using the GCC kit and run it. Sadly the errors above all come up! :(


  • Lifetime Qt Champion

    @qcoderpro Can you upload this project to somewhere so we can test?




  • Lifetime Qt Champion

    @qcoderpro I can build it on Linux without any issues.
    Did you delete the DialogTest.pro.user file after copying to Linux?



  • @jsulm
    yes.
    Now how to recover it or anything to fix the issue please?


  • Lifetime Qt Champion

    @qcoderpro On which file system is the project located?
    Do you have any old build artefacts in the project or build folder?



  • @jsulm

    The project is made and working properly on Windows. Now what should I do to test it on Linux?

    I transferred the project to Linux:

    Screenshot from 2020-05-12 08-44-24.png

    Now I open the IDE (Qt Creator) and open the .pro file. Then I configure the project. But there is only the .pro and main.cpp files on the list!

    Screenshot from 2020-05-12 08-50-19.png

    So I add DialodTest.cpp and DialogTest.h files to the project.

    Screenshot from 2020-05-12 08-52-42.png

    And then run it.
    And suddenly all those errors come up.

    The problem is either with my Qt or Linux! But how to know and fix it?


  • Lifetime Qt Champion

    @qcoderpro There is nothing special to do.
    I downloaded your archive, extracted it, deleted DialogTest.pro.user file, open the pro file in QtCreator and built. That's it.
    So, again: did you delete DialogTest.pro.user before opening project in QtCreator?

    I guess you now added the files twice to the pro file? That would explain the errors you get...


  • Moderators

    @qcoderpro
    start again from scratch. QtCreator does not show the project tree when your compiler setup is messed up. So when you added the files to the project file you added them twice (as @jsulm suggested)

    • Close QtCreator
    • Delete the project
    • Delete the build folder
    • Copy&Extract the project form windows over
    • delete the *.pro.user file
    • open the .pro file with QtCreator
    • Select the correct& working compiler configuration
    • Build the project


  • @J-Hilk

    I added the files "after" configuring the compiler. And now I have not added the files and the IDE doesn't show them either. It's only the .pro and main.cpp. Yet I run it and now I get this error.

    Screenshot from 2020-05-12 09-11-30.png

    I created an empty project "Test_1" and the IDE showed the same errors as above for this one too, so probably it's the source of the issue.

    Screenshot from 2020-05-12 09-12-20.png



  • @qcoderpro it looks like your development machine is missing some OpenGL dev libraries. See this post just in case


  • Lifetime Qt Champion

    @qcoderpro Take a look at https://doc.qt.io/qt-5/linux.html and install libgl1-mesa-dev package as shown there



  • @jsulm

    Thanks so much. Solved.


Log in to reply