0

I'm currently learning Qt by working through examples in the ebook "C+ GUI Programming with Qt 4, Second Edition".

The first example is a "Hello World" application. Following the steps in the example I've been able to create the following files:

  • hello.cpp, by typing out the provided code.
  • hello.pro, by using OS X Terminal command "qmake -project".
  • hello.xcodeproj and info.plist by using command "qmake hello.pro"

However, I am unable to create "hello.app"

The command "make" yields:

"make: *** No targets specified and no makefile found.  Stop."

The command "make hello" yields:

g++     hello.cpp   -o hello
hello.cpp:1:24: error: QApplication: No such file or directory
hello.cpp:2:18: error: QLabel: No such file or directory
hello.cpp: In function ‘int main(int, char**)’:
hello.cpp:6: error: ‘QApplication’ was not declared in this scope
hello.cpp:6: error: expected `;' before ‘app’
hello.cpp:7: error: ‘QLabel’ was not declared in this scope
hello.cpp:7: error: ‘label’ was not declared in this scope
hello.cpp:7: error: expected type-specifier before ‘QLabel’
hello.cpp:7: error: expected `;' before ‘QLabel’
hello.cpp:9: error: ‘app’ was not declared in this scope
make: *** [hello] Error 1

While I can't create "hello.app" from the terminal with these two commands, I can create it by simply opening Xcode and pressing the button "Build and Go".

Can someone tell me why in the world these two commands don't work? And how I can make the "hello.app" from the terminal?

Thanks!

3 Answers 3

1

I see that qmake has generated an *.xcodeproj-file for you. Try running xcodebuild instead of make :)

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Magnus Hoff! xcodebuild did the trick! That's what I needed to know!
Also it's worth to mention, that if you want to generate makefiles instead of xcodeproj, you may call qmake -spec macx-g++
@Kamil Klimek: Thanks. I was looking for that, but somehow never found out :)
0

It looks like you didn't include the directories from the Qt SDK in your makefile paths. Did you also remember to run QMake?

Comments

0

I would suggest you download and install Qt SDK. Then familiar yourself with Qt Creator, the IDE for Qt. It's much easier that way since all the frameworks and docs are installed and configured for you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.