我目前通过在电子书“C + GUI编程与Qt 4第二版”中的示例来学习Qt。从OS X终端编译Qt示例的问题
第一个示例是“Hello World”应用程序。按照示例中的步骤,我已经能够创建以下文件:
- hello.cpp,通过输入提供的代码。
- hello.pro,通过使用OS X终端命令“qmake -project”。
- hello.xcodeproj和info.plist中使用命令 “QMAKE hello.pro”
但是,我无法创建 “hello.app”
命令 “使” 产量:
"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
虽然我不能CREA使用这两个命令从终端输入“hello.app”,我可以通过简单地打开Xcode并按下“Build and Go”按钮来创建它。
有人能告诉我为什么在这个世界上这两个命令不起作用吗?我怎样才能从终端制作“hello.app”?
谢谢!
谢谢Magnus Hoff! xcodebuild做了诡计!这就是我需要知道的! – CrazyFileMaker 2010-11-06 20:42:36
另外值得一提的是,如果你想生成makefile而不是xcodeproj,你可以调用qmake -spec macx-g ++ – 2010-11-09 11:12:24
@Kamil Klimek:谢谢。我正在寻找,但不知何故:) – 2010-11-09 11:27:36