C++、xcode 和终端,绝对基础
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6364852/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C++, xcode and terminal, absolute basics
提问by Michael Watson
I have an Xcode project, just the standard hello world app that comes with xcode for c++. I hit build and run, it runs, it completes, I see nothing.
我有一个 Xcode 项目,只是 xcode for c++ 附带的标准 hello world 应用程序。我点击构建并运行,它运行,它完成,我什么也没看到。
How do I get this to open up in terminal?
我如何让它在终端中打开?
采纳答案by kmikael
shift+cmd+Ybrings up the debugger and console. You can see all the output there. Alternatively, you can choose View from the menu bar and click 'Show Debug Area'. This debug area shows the output of your program just like Terminal.
shift+ cmd+ 调Y出调试器和控制台。你可以在那里看到所有的输出。或者,您可以从菜单栏中选择“查看”并单击“显示调试区域”。这个调试区像终端一样显示程序的输出。
回答by Caleb
Look for your output in Xcode's debugger console. If you want the output to show up in Terminal, run your program from a Terminal window.
在 Xcode 的调试器控制台中查找您的输出。如果您希望输出显示在终端中,请从终端窗口运行您的程序。
Clarification:What I meant is that you should open a Terminal window and run the program from there. The simplest way conceptually is to just type the full path to the program at a command line prompt. In practice, that path is pretty complicated. If you've got a Terminal window open, you can drag the executable from the Products group in your Xcode project right into the Terminal window. This should result in the full path to the program appearing at the command line -- you'll see how complicated it is! Press the return key to complete the command, and you should see "Hello, World!" in your Terminal window.
澄清:我的意思是你应该打开一个终端窗口并从那里运行程序。从概念上讲,最简单的方法是在命令行提示符下键入程序的完整路径。在实践中,这条路非常复杂。如果您打开了一个终端窗口,您可以将可执行文件从 Xcode 项目中的 Products 组拖到终端窗口中。这应该会导致程序的完整路径出现在命令行中——您会看到它有多复杂!按回车键完成命令,你应该看到“Hello, World!” 在您的终端窗口中。
If you're going to do this a lot, you can add a Copy Files build phase to your target's build phases list so that Xcode will automatically copy the executable to someplace where it's easy to get to, like your ~/bin directory. Xcode also used to have a 'custom executable' setting that let you set Terminal as the program to run, but I don't see that in Xcode 4.
如果您要经常执行此操作,可以将 Copy Files 构建阶段添加到目标的构建阶段列表中,以便 Xcode 自动将可执行文件复制到易于访问的某个位置,例如您的 ~/bin 目录。Xcode 还曾经有一个“自定义可执行文件”设置,可让您将终端设置为要运行的程序,但我在 Xcode 4 中看不到这一点。