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

[Solved] Compiling a simple Qt5 application



  • Hello folks,

    I am new to this site, and to Qt as a whole. I have about a year of experience with both (the Ubuntu/Mint/Debian side of) Linux and Java, but none with Qt or C++ (or any truly compiled language). Some Qt5 vids on YouTube and its superiority to GTK+ on other platforms made me try it.

    I am failing to compile some very basic code. "I was trying out this tutorial by 'zetcode.com':":http://www.zetcode.com/gui/qt4/introduction/
    I downloaded and installed Qt5, added '/opt/Qt5.0.2/5.0.2/gcc_64/bin' to the PATH enviroment variable, and stuffed a file entitled 'test' with the example code:
    @
    #include <QApplication>
    #include <QWidget>

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);

    QWidget window;
    
    window.resize(250, 150);
    window.setWindowTitle("Simple example");
    window.show();
    
    return app.exec&#40;&#41;;
    

    }
    @

    In its directory, I executed the following commands:
    @qmake -project (this generates a .pro file with the name of the directory)
    qmake (this generates a 'Makefile')
    make
    make: Nothing to be done for `first'.
    @

    Well, that's basically it. According to the tutorial, 'make' supposed to do something different than saying 'nothing to be done for ` first''. It's probably a really simple switch or flag that needs to be switch, maybe even because this is not Qt4 but Qt5, but I'm out of luck. Could anyone give me a push into the right direction? I would be so happy if this worked :).

    Flash Mustace



  • I solved it. Apperantly, not giving a source file the ".cpp" extension causes either 'make' or 'qmake' to behave weird.
    Anyway, it's fixed now.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Could you post the pro file generated ?


  • Lifetime Qt Champion

    Indeed, file extensions are very important when programming.

    .h for header and .cpp are the most common for c++ (you could use hpp also but it's not as widely used IFAIK)

    qmake uses the file extension to setup the right compiler for your files.


Log in to reply