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. Cannot compile first example of "Qt for Beginners" wiki page
QtWS25 Last Chance

Cannot compile first example of "Qt for Beginners" wiki page

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 3 Posters 6.1k 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.
  • D Offline
    D Offline
    Dekeon
    wrote on 3 Jan 2018, 23:47 last edited by VRonin 1 Apr 2018, 16:47
    #1

    Hi,

    I've followed the first steps of this guide:
    https://wiki.qt.io/Qt_for_Beginners

    I've created an Empty qmake Project. I've then put the following code in my .pro file [Snake.pro] (copy-pasted from the guide) :

    TEMPLATE = app
    TARGET = name_of_the_app
    
    QT = core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    SOURCES +=  main.cpp
    

    Then, I made a C++ source file [main.cpp] in which I put (again, copy-pasted):

    //
    #include <QApplication>
    #include <QPushButton>
    
    int main(int argc, char **argv)
    {
     QApplication app (argc, argv);
    
     QPushButton button ("Hello world !");
     button.show();
    
     return app.exec();
    }
    //
    

    When I try to run it, I get the following errors:

    D:\OneDrive\Documents\C++\Qt\build-Snake-Desktop_Qt_5_10_0_MSVC2013_64bit-Debug\debug\main.o:-1: In function Z5qMainiPPc': D:\OneDrive\Documents\C++\Qt\Snake\main.cpp:6: error: undefined reference to _imp___ZN12QApplicationC1ERiPPci'
    D:\OneDrive\Documents\C++\Qt\Snake\main.cpp:8: error: undefined reference to _imp___ZN11QPushButtonC1ERK7QStringP7QWidget' D:\OneDrive\Documents\C++\Qt\Snake\main.cpp:9: error: undefined reference to _imp___ZN7QWidget4showEv'
    D:\OneDrive\Documents\C++\Qt\Snake\main.cpp:8: error: undefined reference to _imp___ZN11QPushButtonD1Ev' [5 to 10 more undefined reference to errors...] crt0_c.c:-1: error: undefined reference to WinMain@16'
    collect2.exe:-1: error: error: ld returned 1 exit status

    How can I fix this? I'm on Windows 10, and the kit I'm using for my project is Desktop Qt 5.10.0 MinGW 32bit with the selected compiler MinGW 5.3.0 32bit for C++.

    Thanks!

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Charlie_Hdz
      wrote on 3 Jan 2018, 23:54 last edited by
      #2

      Welcome @Dekeon

      Can you try to run a QWidget project?

      Kind Regards,
      Enrique Hernandez
      gearstech.com.mx
      chernandez@gearstech.com.mx

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dekeon
        wrote on 4 Jan 2018, 00:22 last edited by
        #3

        I made a Qt Widget and I got the same result, but with a bunch more errors of the same kind:
        undefined reference to...

        C 1 Reply Last reply 4 Jan 2018, 00:24
        0
        • D Dekeon
          4 Jan 2018, 00:22

          I made a Qt Widget and I got the same result, but with a bunch more errors of the same kind:
          undefined reference to...

          C Offline
          C Offline
          Charlie_Hdz
          wrote on 4 Jan 2018, 00:24 last edited by
          #4

          @Dekeon said in Can not compile first example of "Qt for Beginners" wiki page:

          I made a Qt Widget and I got the same result, but with a bunch more errors of the same kind:
          undefined reference to...

          Please go to Tools->Options->Build&Run and take a screenshot of the Kits tab

          Kind Regards,
          Enrique Hernandez
          gearstech.com.mx
          chernandez@gearstech.com.mx

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Dekeon
            wrote on 4 Jan 2018, 00:42 last edited by
            #5

            It's quite a mess, I've made default the only kit which doesn't have a red exclamation sign.

            0_1515026537400_Untitled.png

            1 Reply Last reply
            0
            • C Offline
              C Offline
              Charlie_Hdz
              wrote on 4 Jan 2018, 00:46 last edited by
              #6

              Can you add widget in the following way (file .pro)?

              QT = core gui widgets

              Kind Regards,
              Enrique Hernandez
              gearstech.com.mx
              chernandez@gearstech.com.mx

              1 Reply Last reply
              0
              • D Offline
                D Offline
                Dekeon
                wrote on 4 Jan 2018, 00:49 last edited by
                #7

                @Charlie_Hdz said in Cannot compile first example of "Qt for Beginners" wiki page:

                QT = core gui widgets

                Tried in both the projects, getting the same errors still.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  Charlie_Hdz
                  wrote on 4 Jan 2018, 00:50 last edited by
                  #8

                  Here is another solution:

                  You have a mismatch between VS libraries and MINGW... Trying downloading the VS kit from https://www1.qt.io/download/

                  Kind Regards,
                  Enrique Hernandez
                  gearstech.com.mx
                  chernandez@gearstech.com.mx

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    Dekeon
                    wrote on 4 Jan 2018, 00:55 last edited by
                    #9

                    What does VS stand for? I don't see anything resembling VS kit to download anywhere. Do I have to redownload the open source?

                    J 1 Reply Last reply 4 Jan 2018, 04:12
                    0
                    • C Offline
                      C Offline
                      Charlie_Hdz
                      wrote on 4 Jan 2018, 01:01 last edited by
                      #10

                      I got the same issue a time ago, having VS and using Qt Creator in the same OS...

                      Show me the issue description of the kits.
                      Can you delete all the kits that had issues.
                      Display the DEsktop MinGW kit and show me the information there.

                      Kind Regards,
                      Enrique Hernandez
                      gearstech.com.mx
                      chernandez@gearstech.com.mx

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        Dekeon
                        wrote on 4 Jan 2018, 01:32 last edited by
                        #11

                        Here's the informations about a kit with a red sign:

                        0_1515029089461_Untitled.png

                        Here's the one I've selected as default:

                        0_1515029136940_test.png

                        I can't seem to be able to delete the ones that are marked red. I've tried the maintenance tool, but I don't know what to de-select and if it's even the right thing to do. Here's my maintenance tool selection screen anyways:

                        0_1515029547122_test2.png

                        1 Reply Last reply
                        0
                        • D Dekeon
                          4 Jan 2018, 00:55

                          What does VS stand for? I don't see anything resembling VS kit to download anywhere. Do I have to redownload the open source?

                          J Offline
                          J Offline
                          JKSH
                          Moderators
                          wrote on 4 Jan 2018, 04:12 last edited by JKSH 1 Apr 2018, 04:26
                          #12

                          @Dekeon said in Cannot compile first example of "Qt for Beginners" wiki page:

                          What does VS stand for? I don't see anything resembling VS kit to download anywhere.

                          "VS" stands for "Visual Studio" by Microsoft. It is also known as "MSVC" ("Microsoft Visual C/C++").

                          If you want to use a VS/MSVC kit, then you need to download Visual Studio from Microsoft. However, since you already have MinGW installed, you can just use the MinGW kit.

                          @Dekeon said in Cannot compile first example of "Qt for Beginners" wiki page:

                          I can't seem to be able to delete the ones that are marked red. I've tried the maintenance tool, but I don't know what to de-select and if it's even the right thing to do. Here's my maintenance tool selection screen anyways:

                          0_1515029547122_test2.png

                          The red exclamation marks are there because you have installed kits that you can't use (for example, you haven't installed MSVC so you can't use the MSVC kits).

                          Expand "Qt 5.10.0" and untick all the MSVC, UWP, and Android kits. Make sure you leave the MinGW kit installed.

                          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                          1 Reply Last reply
                          0
                          • C Offline
                            C Offline
                            Charlie_Hdz
                            wrote on 4 Jan 2018, 15:43 last edited by Charlie_Hdz 1 Apr 2018, 15:44
                            #13

                            @Dekeon

                            To expand @JKSH explanation... I did a test in my rusty Windows (I prefer Linux) with your code. It compiled.

                            I attached some figures for your reference in the Compiler/Kits configuration. (Qt 5.7.1 (MSVC 2015 32 bits)

                            2_1515080555570_dekeon2.png 1_1515080555570_dekeon3.png 0_1515080555569_dekeon1.png

                            Hope your application works.. I remembered that I had issues when I got Qt Creator when I had VS installed. So feel accompanied!

                            Kind Regards,
                            Enrique Hernandez
                            gearstech.com.mx
                            chernandez@gearstech.com.mx

                            1 Reply Last reply
                            1
                            • D Offline
                              D Offline
                              Dekeon
                              wrote on 4 Jan 2018, 17:58 last edited by
                              #14

                              It works!!!! It was just a matter of removing the MSVC, UWP and Android kits! Thank you guys for your help!

                              1 Reply Last reply
                              1
                              • C Offline
                                C Offline
                                Charlie_Hdz
                                wrote on 4 Jan 2018, 18:01 last edited by
                                #15

                                @Dekeon

                                Good news, can you set the thread as Solved, please?

                                Kind Regards,
                                Enrique Hernandez
                                gearstech.com.mx
                                chernandez@gearstech.com.mx

                                1 Reply Last reply
                                1

                                3/15

                                4 Jan 2018, 00:22

                                topic:navigator.unread, 12
                                • Login

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