【发布时间】:2010-11-06 20:23:16
【问题描述】:
我目前正在通过阅读电子书“C+ GUI Programming with Qt 4, Second Edition”中的示例来学习 Qt。
第一个示例是“Hello World”应用程序。按照示例中的步骤,我已经能够创建以下文件:
- hello.cpp,输入提供的代码。
- hello.pro,通过使用 OS X 终端命令“qmake -project”。
- hello.xcodeproj 和 info.plist 使用命令“qmake hello.pro”
但是,我无法创建“hello.app”
命令“make”产生:
"make: *** No targets specified and no makefile found. Stop."
命令“打招呼”产生:
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”?
谢谢!
【问题讨论】: