我目前正在通过阅读电子书“使用Qt 4进行C + GUI编程,第二版”中的示例来学习Qt。
第一个示例是“ Hello World”应用程序。按照示例中的步骤,我已经能够创建以下文件:
hello.cpp,通过键入提供的代码。
hello.pro,使用OS X终端命令“ qmake -project”。
使用命令“ qmake hello.pro”获取hello.xcodeproj和info.plist
但是,我无法创建“ hello.app”
命令“ make”产生:
"make: *** No targets specified and no makefile found. Stop."
命令“ make hello”产生:
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
虽然我无法使用这两个命令从终端创建“ hello.app”,但可以通过简单地打开Xcode并按“ Build and Go”按钮来创建它。
有人可以告诉我为什么这两个命令不起作用吗?以及如何从终端制作“ hello.app”?
谢谢!
最佳答案
我看到qmake
为您生成了一个*.xcodeproj
文件。尝试运行xcodebuild
而不是make
:)