Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I compiled and run programs?

How can I compiled and run programs?

Scheduled Pinned Locked Moved General and Desktop
18 Posts 5 Posters 5.7k Views
  • 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.
  • A Offline
    A Offline
    ArbolOne
    wrote on last edited by
    #1

    Hey, kids
    I created a new Project, Qt Created this file for me
    #include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow){
    ui->setupUi(this);
    }

    MainWindow::~MainWindow(){
    delete ui;
    }

    I then clicked on the green arrow, I ~think the program compiled, then I pressed Ctr-R, but I got the same results. How can I compiled and run this program?

    This is not the first time you've been here, at the end you've always lost. You create viruses and we the cure, and in this battle you've always lost.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Please wrap your code in '@' tags.

      [quote]but I got the same results[/quote]

      What were those results? Any warings, error messages, etc? Also, please add which Qt version, compiler and operating system are you on.

      (Z(:^

      1 Reply Last reply
      0
      • musimbateM Offline
        musimbateM Offline
        musimbate
        wrote on last edited by
        #3

        Here is a good tutorial on "building and running an example":http://qt-project.org/doc/qtcreator-2.6/creator-build-example-application.html .You should have a good grasp after you go through it.

        Why join the navy if you can be a pirate?-Steve Jobs

        1 Reply Last reply
        0
        • musimbateM Offline
          musimbateM Offline
          musimbate
          wrote on last edited by
          #4

          This is a good link to a "youtube video":http://www.youtube.com/watch?v=Id-sPu_m_hE that would help

          Why join the navy if you can be a pirate?-Steve Jobs

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            QMartin
            wrote on last edited by
            #5

            Hello

            The green arrow button and Ctrl+R produce the same result: compile and run, whereas the hammer button just compiles. Follow musimbate's posted links to learn more.

            Regards

            1 Reply Last reply
            0
            • A Offline
              A Offline
              ArbolOne
              wrote on last edited by
              #6

              @
              #include <QCoreApplication>
              #include <iostream>
              #include <QDebug>

              int main(int argc, char *argv[])
              {
              QCoreApplication a(argc, argv);
              qDebug << "Hello world";
              std::cin.get();

              return a.exec&#40;&#41;;
              

              }
              @
              According to the video tutorial, after clicking on the green arrow I should be able to see a console window, but I don't get anything, absolutely nothing!
              Please note that @#include <iostream>@ is not recognized as a valid header-file and qt underlines it. Needless to say is that none of the std library is recognized.
              I am using VS10 Express edition as well as qt-windows-opensource-5.0.0-msvc2010_32-x86-offline.

              Thanks!

              This is not the first time you've been here, at the end you've always lost. You create viruses and we the cure, and in this battle you've always lost.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                ArbolOne
                wrote on last edited by
                #7

                ah, progress, if we can call it that.
                After trying again, I got this message!

                Starting D:\dev\qt\qtTest1-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Debug\debug\qtTest1.exe...
                Cannot change to working directory 'D:/dev/qt/qtTest1-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Debug': The system cannot find the file specified.

                D:\dev\qt\qtTest1-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Debug\debug\qtTest1.exe exited with code -1
                I

                This is not the first time you've been here, at the end you've always lost. You create viruses and we the cure, and in this battle you've always lost.

                1 Reply Last reply
                0
                • sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #8

                  Don't know how it works on Windows, but you can turn off checkbox "Run in Terminal" in your project settings, and then QtC will show you result in the application output pane.

                  Does that path exist? What happens when you turn shadow building off?

                  (Z(:^

                  1 Reply Last reply
                  0
                  • musimbateM Offline
                    musimbateM Offline
                    musimbate
                    wrote on last edited by
                    #9

                    I think you should try to install those SDKs that have everything set up for you.It helps you focus on Qt rather than spend time trying to get the set up right.

                    If you have a linux platform go to your command line and type the following:
                    @sudo apt-get install build-essential qt4-designer qtcreator
                    qtcreator-doc qt4-demos qt4-doc qt4-dev-tools libqt4-dev@
                    it should set up everything for you.It is not the latest Qt but it works .I am sorry i dont have a quick link to a windows SDK,I ll post it here as soon as i find it.
                    Hope this helps.

                    Why join the navy if you can be a pirate?-Steve Jobs

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      ArbolOne
                      wrote on last edited by
                      #10

                      I see, it sounds like Qt does provide cross platform code, but it just does not install well across in all other platforms but Linux, or perhaps the version I am using (Five 0) is not really ready for WinOS.
                      Are previous versions of Qt better suited for WinOS?
                      Are lower versions still available? and if so, where do I get them?

                      TIA

                      This is not the first time you've been here, at the end you've always lost. You create viruses and we the cure, and in this battle you've always lost.

                      1 Reply Last reply
                      0
                      • sierdzioS Offline
                        sierdzioS Offline
                        sierdzio
                        Moderators
                        wrote on last edited by
                        #11

                        Have tried turning shadow building off?

                        Qt 4.7 and Qt 4.8 are still active branches,and will continue to receive bug fixes for some time. You can find them in the same place everything else is - in the Downloads section.

                        (Z(:^

                        1 Reply Last reply
                        0
                        • musimbateM Offline
                          musimbateM Offline
                          musimbate
                          wrote on last edited by
                          #12

                          The latest version of Qt has installed with no problem on my windows 7.Just go to the "download page ":http://qt-project.org/downloads and chose Qt 5.0.1 for Windows 32-bit (MinGW 4.7, 823 MB).I assume you are working on a windows platform since you mentioned MSVC2010.

                          Why join the navy if you can be a pirate?-Steve Jobs

                          1 Reply Last reply
                          0
                          • sierdzioS Offline
                            sierdzioS Offline
                            sierdzio
                            Moderators
                            wrote on last edited by
                            #13

                            No reason to download MinGW when he already has MSVC installed.

                            (Z(:^

                            1 Reply Last reply
                            0
                            • musimbateM Offline
                              musimbateM Offline
                              musimbate
                              wrote on last edited by
                              #14

                              Hey sierdzio,what does shadow building exactly do,I would appreciate it if you explained a bit or pointed to a place i could learn about it.
                              Thanks.

                              Why join the navy if you can be a pirate?-Steve Jobs

                              1 Reply Last reply
                              0
                              • sierdzioS Offline
                                sierdzioS Offline
                                sierdzio
                                Moderators
                                wrote on last edited by
                                #15

                                Newer builds of Qt Creator (I think it begun with 2.2 or around that release) default to use of shadow building. It basically means that the IDE changes output folders specified by the build system (qmake in most cases) and places the result in another directory, a shadow build directory, usually outside the source directory. A bit annoying to some people like me, but it seems to be a general trend (Xcode, VS are doing the same), and does indeed have advantages to it.

                                (Z(:^

                                1 Reply Last reply
                                0
                                • musimbateM Offline
                                  musimbateM Offline
                                  musimbate
                                  wrote on last edited by
                                  #16

                                  Thanks ,i have seen it for some time and never really took time to explore it.I'm glad you mentioned it

                                  Why join the navy if you can be a pirate?-Steve Jobs

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    Sam
                                    wrote on last edited by
                                    #17

                                    [quote author="musimbate" date="1360324098"]Hey sierdzio,what does shadow building exactly do,I would appreciate it if you explained a bit or pointed to a place i could learn about it.
                                    Thanks.[/quote]

                                    I would like to add few points

                                    [quote author="Tobias Hunger" date="1358331843"][/quote]

                                    Shadow-building has lots of advantages, too, so that is why we encourage its use so much: You can switch between different kinds of builds without having to clean/rebuild, you keep your source dir clean, you avoid trouble when working with different configurations, etc. It really is the good-thing(TM).

                                    [quote author="sierdzio" date="1360324508"] A bit annoying to some people like me, but it seems to be a general trend (Xcode, VS are doing the same)[/quote]

                                    You can in fact turn off shadow building from the wizard: Just set the build directory to the source directory. In 2.7 there is a way to change the default build directory in Tools>Options>Build & Run>General. Setting it to '.' will effectively turn of shadow building globally.

                                    "Reference":http://qt-project.org/forums/viewthread/23812/#post_reply

                                    1 Reply Last reply
                                    0
                                    • A Offline
                                      A Offline
                                      ArbolOne
                                      wrote on last edited by
                                      #18

                                      Qt5 comes with its own IDE and RAD, and it works well with MSVC and MinGW. MSVC is very extensive and carries with it a heavy load that is all installed in the HDD. I find MinGW to be better suited for Qt5 for this particular reason.
                                      But in this world, good things don't come easy, that is why we appreciate them so much. When installing qt-win-opensource-4.8.4-mingw, I get this message:
                                      —————————————-
                                      Qt OpenSource 4.8.4 Setup
                                      —————————————-
                                      There is a problem with your MinGW installation:

                                      g++ not found in C:\MinGW\bin\

                                      Do you still want to continue? (Your installation may not work)
                                      —————————————-
                                      Yes No
                                      —————————————-

                                      which is true, since MinGw was installed in the D:\ drive and not in the C:\ drive. Please note I have added MinGW to the path and 'echo %path%' confirms it, so the path has it, but the Qt installer does not see it.
                                      How can I solve this problem?
                                      Reinstalling MinGW in the C:\ drive is a choice, but I would rather any other option.

                                      Thanks in advance

                                      This is not the first time you've been here, at the end you've always lost. You create viruses and we the cure, and in this battle you've always lost.

                                      1 Reply Last reply
                                      0

                                      • Login

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • Users
                                      • Groups
                                      • Search
                                      • Get Qt Extensions
                                      • Unsolved