|
|
Did you try to open the gdb window? Usually NSLog() outputs to there, probably the same for cout.
|
In terminal, cd to the directory the cpp file is in.
If you want to use GNU C++ compiler,
g++ filename.cpp -o executable_name
To run: ./executable_name <arguments>
|
Sorry but how to you open the gdb window (what's gdb? sorry it's my first time working around this).
and I don't know how to open the terminal, it's not in the apple menu..
|
On November 14 2010 13:41 SilverSkyLark wrote:Sorry but how to you open the gdb window (what's gdb? sorry it's my first time working around this). and I don't know how to open the terminal, it's not in the apple menu..
gdb is the gnu debugger.
Usually when you compile and run your Xcode projects, a little bar pops up the coding area with some buttons. One of these buttons, which, if im not mistaken, has a terminal drawed on it, will open the gdb window.
Maybe compiling directly through the terminal is better. You find it on Applications -> Utility (not sure if its named Utility or System Tools, the Mac I am forced to use in the reasearch lab is in portuguese).
|
You may need to add a command to pause the program before it exits. Some IDEs add this automatically (depending on settings). Adding a getch() or something like that will force the program to wait before exiting.
Trying adding: char c = getch();
between the cout line and return 0.
stdio should probably be included as <cstdio> as well, though it should work the way it is now.
|
For simple assignments in an algorithms class, I'd strongly recommend just using GCC rather than trying to deal with any IDE. Just run it in the OS X Terminal as zoombini and fabiano said. It's in /Applications/Utilities.
|
I managed to open the terminal and get to open gdb by typing gdb in
ok more noob questions, how to I compile programs there? typed in help and I can't see anything that can specifically help me.
edit: I'll look for a gcc that would work in osx 10.4...if that doesn't give me anything, I'll borrow my dad's laptop and work there. thanks for the help guys..
|
GCC is the C compiler. G++ is the C++ compiler. They both should already be installed on your Mac OS X installation.
Like I said earlier, to compile your program cd into the directory where the .cpp (or .cpp files are).
Type this into your terminal: g++ your_cpp.cpp -o executable_name_you_want
If you have compile errors, it will tell you in terminal. If you do not get any errors, then you are golden.
If compile is successful, then type "ls" into terminal. This will list your current directory. If compile is successful, you will see executable_name_you_want listed. (Maybe type "ls | grep executable_name_you_want".)
To run the executable that you've compiled, type: ./executable_name_you_want
Your program should run.
|
|
|
|