Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [Solved]Link errors with Qt Creator on C++ examples out of the box
QtWS25 Last Chance

[Solved]Link errors with Qt Creator on C++ examples out of the box

Scheduled Pinned Locked Moved Installation and Deployment
6 Posts 2 Posters 6.3k 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.
  • M Offline
    M Offline
    mrplainswalker
    wrote on last edited by
    #1

    I'm brand new to both Qt and Qt Creator, so forgive my ignorance if you will. I just installed the QtSDK 4.7.3 on Windows 7 and tried to build a hello world program:

    @#include <QtGUI/QApplication>
    #include <QtGUI/QPushButton>

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

    QPushButton hello("Hello world!");
    hello.resize(100, 30);
    
    hello.show();
    return app.exec&#40;&#41;;
    

    }
    @

    I immediately get link errors about undefined references to the following symbols:

    _imp___ZN12QApplicationC1ERiPPci
    _imp___ZN11QPushButtonC1ERK7QStringP7QWidget
    _imp___ZN12QApplication4execEv
    _imp___ZN12QApplication4execEv
    _imp___ZN12QApplicationD1Ev

    I'm not sure how Qt Creator knows what my include and library paths are. I was getting these errors even before adding anything extra to my PATH variable. The only Qt related thing in my PATH was the bin folder for mingw. Clearly, it's finding the header files, but it doesn't seem to be finding the library files. I get the same errors when trying to build the examples as well.

    I tried adding the path to the library folder to my PATH variable (in my case it was C:\QtSDK\Desktop\Qt\4.7.3\mingw\lib) but that didn't work.

    Any help would be greatly appreciated.

    [EDIT: code formatting, please wrap in @-tags, Eddy]

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      (Be sure and wrap your code in "@" tags, not <div> tags)

      What does your .pro file look like?

      As an aside...

      Also, even though Windows' filenames are case-insensitive, you should use

      @
      #include <QtGui/QApplication>
      #include <QtGui/QPushButton>
      @

      rather than "QtGUI"

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mrplainswalker
        wrote on last edited by
        #3

        Thanks for the advice. My .pro file is unchanged from the default. It looks like the following:

        @QT += core

        QT -= gui

        TARGET = HelloWorld
        CONFIG += console
        CONFIG -= app_bundle

        TEMPLATE = app

        SOURCES += main.cpp@

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #4

          You need to remove line 3 from your .pro file. It looks like you started with a console application template, which disables all of the GUI elements by default (and, as such, keeps them from linking.)

          You probably don't need line 6 either.

          Your best bet would be to use the "Qt Widget -> Qt Gui Application" template when creating a new project.

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mrplainswalker
            wrote on last edited by
            #5

            Thanks, that worked. I'll have to read up on project file syntax.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mlong
              wrote on last edited by
              #6

              You're welcome! Good luck!

              (Be sure to edit the title of your post to add [Solved] to the beginning.)

              Software Engineer
              My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

              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