using gcc on mac

cappucino_choco

Registered
i recently brought my self an ibook, and i have no idea on how to compile th
e c++ programs on mac gcc :(
I heard you can compile c or c++ programs using both terminal(darwin) or xco
de, but i dont know how to operate both compiler
i'll be really glad if someone can help me out

thanks in advance ^-^
 
Well you install XCode and then create a project using your source files then compile them and you can also use gcc from the terminal to compile but doing it this way is probably only a good idea for linux or bsd source code porting.
 
heya i've downloaded xcode, i saw the source code compiled but i cant really see the output of my programs? is there anyway to make the output visible?

thanks ^^
 
Look in the xcode console, but if you need to do both input and output you are better running the program from terminal.app.
 
The Terminal program is in the Application Utilities folder.

When you start the terminal a console appears and it's very similar to the Linux console so if you want to learn some more about it there are stacks of Linux console tutorials on the net.

For instance if I type gcc -v and then hit return gcc starts up and prints it's version number to the console.

If I want to compile a simple console program with text only output I'd use something like gcc simple.c -o simple.

Something like this for simple.c

#include <stdio.h>

main()
{
printf("hello\n");
}

then I'd drag the simple.c to the Applications folder and open up a terminal and change to the Applications folder using a cd /Applications and then run
gcc simple.c -o simple and hopefully a program named simple should appear in the Applications folder which will run and print hello when I click on it.

Carbon compiling is really for GUI Apps.
 
Back
Top