PDA

View Full Version : C++ in Xcode 3.2




dissolve
Oct 13, 2009, 10:24 PM
Ok this is probably a simple question with an answer I just can't find, but I'm having an issue with writing C++ in Xcode. Before snow leopard (in the previous version of Xcode), I could write a program, hit "build and go", the code would compile and execute in a terminal-like window. Now, the only way I can get it to execute is opening the executable in the project window. Build and run seems to compile and then do nothing.

Any way to return to the functionality I'm used to? Still pretty new to this so any help is greatly appreciated. Thanks



Cromulent
Oct 14, 2009, 06:04 AM
Ok this is probably a simple question with an answer I just can't find, but I'm having an issue with writing C++ in Xcode. Before snow leopard (in the previous version of Xcode), I could write a program, hit "build and go", the code would compile and execute in a terminal-like window. Now, the only way I can get it to execute is opening the executable in the project window. Build and run seems to compile and then do nothing.

Any way to return to the functionality I'm used to? Still pretty new to this so any help is greatly appreciated. Thanks

Open the Console window when you click build and run.

dissolve
Oct 14, 2009, 01:18 PM
Open the Console window when you click build and run.

While that works, it seems to me to be the same as opening the executable from the organizer window. Any way for this to be automated like it was previously, in which "build and run" compiles and opens a results window?

Cromulent
Oct 14, 2009, 01:51 PM
While that works, it seems to me to be the same as opening the executable from the organizer window. Any way for this to be automated like it was previously, in which "build and run" compiles and opens a results window?

Yes. You need to set the option in the Preferences (the same way you had too in previous versions of Xcode).

dissolve
Oct 14, 2009, 05:52 PM
Yes. You need to set the option in the Preferences (the same way you had too in previous versions of Xcode).

I must be seriously missing something because I've looked through preferences several times and cannot find any option that resembles what I'm hoping for. I didn't have to alter anything with the previous version of Xcode so that's why I'm lost here. Thanks for your help so far.

szymczyk
Oct 14, 2009, 06:59 PM
Go to the Debugging preferences. Choose Show Console from the On Start pop-up menu.

dissolve
Oct 14, 2009, 07:46 PM
Go to the Debugging preferences. Choose Show Console from the On Start pop-up menu.

And there it is...that worked :) I swear I tried that earlier and it did nothing but all is well now. Thank you both for your help.

Another question though...is this actually executing the program as it would by opening the UNIX executable? Just curious, but why not display in a terminal window?

szymczyk
Oct 15, 2009, 02:14 PM
It's using a pseudo terminal for the input and output. For simple programs there shouldn't be a difference between running in Xcode and the Terminal.

As to why the input and output aren't displayed in a Terminal window, my guess is that Apple wants you to be able to do everything in Xcode. By providing the debugging console, you don't have to launch the Terminal application to perform command-line input and output.

dissolve
Oct 15, 2009, 05:58 PM
It's using a pseudo terminal for the input and output. For simple programs there shouldn't be a difference between running in Xcode and the Terminal.

As to why the input and output aren't displayed in a Terminal window, my guess is that Apple wants you to be able to do everything in Xcode. By providing the debugging console, you don't have to launch the Terminal application to perform command-line input and output.

Alright, that's a fair enough interpretation. While I did prefer the old behavior, this seems to be doing the exact same thing for my purposes. I guess the executable is only a few clicks away if there's ever a reason to run that. Thank you for your help everyone.