简体   繁体   中英

C++, xcode and terminal, absolute basics

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.

How do I get this to open up in terminal?

shift + cmd + Y brings 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.

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM