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. Unable to build my first QT Application
Forum Updated to NodeBB v4.3 + New Features

Unable to build my first QT Application

Scheduled Pinned Locked Moved Installation and Deployment
7 Posts 3 Posters 2.6k Views 1 Watching
  • 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 Offline
    F Offline
    falcon03
    wrote on last edited by
    #1

    Hi all,

    I'm new to developing with QT, but I'd like to develop c++ application using this framework.

    Since I'm blind and QT Creator has some important accessibility issues in Mac OS X, I thought I could develop QT-Based applications using the QMake command line tool. However, I am not able to build my first application. Running QMake to generate the makefile doesn't give me any warning nor error, but running the make command I get the following output:

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.6 -o ts.app/Contents/MacOS/ts -F/Users/my_username/Downloads/qt_src/qtbase/lib -framework QtGui -framework QtCore -framework OpenGL -framework AGL
    Undefined symbols for architecture x86_64:
    "_main", referenced from:
    start in crt1.10.6.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [ts.app/Contents/MacOS/ts] Error 1

    The app is named ts. Here's the ts.pro file content:

    TEMPLATE = app
    TARGET = ts
    QT = core gui
    sources += main.cpp

    And here's my very very simple main.cpp content:
    #include <QApplication>

    using namespace std;

    int main(int argc, char* *argv) {
    QApplication myApp(argc, argv);
    return(myApp.exec());
    }

    After running make, I get an app bundle, but I cannot run it; Mac OS X tells me that it is damaged or incomplete and, in fact, it misses the main executable.

    I'm running Mac OS X 10.9.2; I'm using QT 5.2.1 and I have installed Xcode 5.1. Not sure if this is important, but since the QT Installer is not accessible, I built QT from source.

    Any help is very appreciated, since I don't know what to do to solve the problem. Thanks in advance.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      sources keyword should be all CAPITAL

      @
      TEMPLATE = app
      TARGET = ts
      QT = core gui
      SOURCES += main.cpp
      @

      1 Reply Last reply
      0
      • F Offline
        F Offline
        falcon03
        wrote on last edited by
        #3

        Hi andreyc,

        thank you very much for your help. I really didn't notice that. :-)

        Now I'm getting another error, though; when I run make, it tells me that it cannot find the QApplication file. So I guess QMake doesn't know where the QT libraries are; how can I supply this information, so that it can find the needed files?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #4

          QApplication is a part of QWidgets framework
          see here "the list of all modules in Qt5":http://qt-project.org/doc/qt-5/qmake-variable-reference.html#qt that qmake will recognize.

          to make QApplication visible to qmake set QT += widgets
          @
          TEMPLATE = app
          TARGET = ts
          QT += widgets
          SOURCES += main.cpp
          @

          1 Reply Last reply
          0
          • F Offline
            F Offline
            falcon03
            wrote on last edited by
            #5

            Hi andreyc,

            once again, thank you very much. I finally got my first QT Application running on Mac OS X! :-)

            I could never immagine that QT core and QT GUI weren't enough to get the QApplication file; in fact, I wrote the pro file following this tutorial:

            http://qt-project.org/wiki/Qt_for_beginners_Hello_World

            Is there any way to report that the documentation is incorrect?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              This article might have been written with Qt 4 in mind. Anyway I've updated it so it's also valid for Qt 5.

              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
              0
              • A Offline
                A Offline
                andreyc
                wrote on last edited by
                #7

                Hi falcon03,
                The images in your page are not available.

                You don't need to assign QT to gui and core, these modules are included by default. In fact if you want to create a console application or a library then you have to disable gui module
                @
                QT -= gui
                @

                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