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. I cannot compile a simple "hello" project

I cannot compile a simple "hello" project

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 4.1k 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.
  • M Offline
    M Offline
    mcancelado
    wrote on last edited by
    #1

    I have been programming for a number of years C/C++ and GUI with Windows forms. I am interested in learnig Qt4 and I downloaded the QtSDK 4.7.3 for OS X Lion (I have a Mac computer with this OS with Xcode.app 4.1). Following a "qmake Tutotrial" in the "qmake Manual" I set a "hello" project with the following files:

    "hello.h"
    #include <QPushButton>

    class MyPushButton : public QPushButton
    {
    public:
    MyPushButton(const QString &text;);
    };

    "hello.cpp"
    #include <QDebug>
    #include "hello.h"

    MyPushButton::MyPushButton(const QString &text;)
    : QPushButton(text)
    {
    setObjectName("mypushbutton");
    qDebug() << "My PushButton has been constructed";
    }

    "main.cpp"
    #include <QApplication>
    #include "hello.h"

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

    MyPushButton helloButton("Hello world!");
    helloButton.resize(100, 30);
    
    helloButton.show();
    return app.exec();
    

    }

    I have created a"hello.pro" file
    CONFIG += qt
    HEDERS += hello.h
    SOURCES += hello.cpp
    SOURCES =+ main.cpp

    I have all these files in a subdirectory "Users/[my name]/Documents. Following the instructions of the tutorial I opened "Terminal" change to the directory where my files are and typed:
    qmake -o Makefile hello.pro.

    Terminal came back with:
    -bash: qmake: command not found

    I tried a number of different things with the same result. For example I found "qmake" in "Users/[my name]/QtSDK/Desktop/Qt/473/gcc/bin". I put a copy of "qmake" in the subdirectory with the other files with the same result. I also deleted the QtSDK and installed it again, rebooted my computer, etc.

    Then I tried something else; I opened Qt Creator.app (version 2.2.1) and I did "File->New File or Project->Other Project->Empty Qt Project". A called this project "hello", I set up as "Target" "Desktop". Then, within QT Creator I clicked on "Buil All" and I get an error message "No rule to make target 'hello.cpp' needed by 'hello.o". Stop.

    By the way I ran some of the examples in Qt Creator and the work correctly.

    I will appreciate any ideas about compiling this project.

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      Hi mcII,

      Welcome to the devnet forum!

      Could put your code in @ tags or use the button with <> on it on top of this editor? That makes it more readable.

      You could also make a new project based on this "tutorial":http://doc.qt.nokia.com/4.7/gettingstartedqt.html. I'm not sure which qmake tutorial you used. Could be an old one. Since you are a GUI guy i think you like it better ;)

      Did you use the general console ? You should use the one you can find in the Qt group, which has all the needed paths set in. Go to start > Qt > ...console (or something like that)

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rokemoon
        wrote on last edited by
        #3

        Try this "tutorial":http://doc.qt.nokia.com/4.7-snapshot/install-mac.html. You need to set the environment variables, because your console right now knows nothing about where to find qmake and qt libs.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Chuck Gao
          wrote on last edited by
          #4

          Some mistakes when writing pro file
          @
          HEDERS += hello.h
          SOURCES += hello.cpp
          SOURCES =+ main.cpp
          @

          to

          @
          HEADERS += hello.h
          SOURCES += hello.cpp
          main.cpp
          @

          Maybe still have some problem, i think you should try some example code first :D

          Chuck

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rokemoon
            wrote on last edited by
            #5

            [quote author="Chuck Gao" date="1312040115"]Some mistakes when writing pro file
            @
            HEDERS += hello.h
            SOURCES += hello.cpp
            SOURCES =+ main.cpp
            @
            [/quote]

            I think mcII sealed when post this, because he would have caught the error at compile time.
            Although what I'm saying he's not yet compiled :-D

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

              Thank you for your help. My background is from the "old" school of MS DOS but so far I have very little knowledge of the equivalent in the Mac world. I have no clue about setting environment variables in Mac I don't want to use this forum to learn these basics.
              I will look for books where I can learn as much as I need of the Mac Terminal. If after my education effort I have problems, I will come to this forum for help. Thanks again.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rokemoon
                wrote on last edited by
                #7

                [quote author="mcII" date="1312043464"]Thank you for your help. My background is from the "old" school of MS DOS but so far I have very little knowledge of the equivalent in the Mac world. I have no clue about setting environment variables in Mac I don't want to use this forum to learn these basics.
                I will look for books where I can learn as much as I need of the Mac Terminal. If after my education effort I have problems, I will come to this forum for help. Thanks again.[/quote]

                Everything is fine, this forum was created for this purpose and you can ask about all.

                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