Solved GCC Desktop Kit yellow mark on Linux
-
Then install the "build-essential" package.
-
Is it a package I can install by Terminal?
-
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 ?
-
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?
-
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.
-
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:
-
That's strange, I would nuke the build folder and re-build from scratch.
-
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! :(
-
@qcoderpro Can you upload this project to somewhere so we can test?
-
@jsulm
Yes, I uploaded it here: https://www.dropbox.com/s/xuji3ghpbvsy5u8/DialogTest.7z?dl=0 -
@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? -
@qcoderpro On which file system is the project located?
Do you have any old build artefacts in the project or build folder? -
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:
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!
So I add DialodTest.cpp and DialogTest.h files to the project.
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?
-
@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...
-
@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
-
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.
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.
-
@qcoderpro it looks like your development machine is missing some OpenGL dev libraries. See this post just in case
-
@qcoderpro Take a look at https://doc.qt.io/qt-5/linux.html and install libgl1-mesa-dev package as shown there
-
Thanks so much. Solved.