Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Solved] Compiling a simple Qt5 application

    Installation and Deployment
    2
    4
    1233
    Loading More Posts
    • 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.
    • F
      FlashMustace last edited by

      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

      1 Reply Last reply Reply Quote 0
      • F
        FlashMustace last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          Hi and welcome to devnet,

          Could you post the pro file generated ?

          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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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.

            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 Reply Quote 0
            • First post
              Last post