Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

luckydev

macrumors newbie
Original poster
Sep 8, 2010
4
0
Hi,

I have just come to Mac world from Linux world and I love my way around in Mac environment. I want to write and practice simple C programs in mac and I was searching for the tools I require. Most (All) of the resources in the web ask me to use XCode as IDE to do programming in C on Mac. XCode, for my purpose seems to be an overkill. I am in no way interested in developing iPhone or Mac GUI application. All I want is

enter C programs using a text editor,
compile it ,
and get the output in a Console.
How can I do it ?

Thanks.
 

MorphingDragon

macrumors 603
Mar 27, 2009
5,160
6
The World Inbetween
Hi,

I have just come to Mac world from Linux world and I love my way around in Mac environment. I want to write and practice simple C programs in mac and I was searching for the tools I require. Most (All) of the resources in the web ask me to use XCode as IDE to do programming in C on Mac. XCode, for my purpose seems to be an overkill. I am in no way interested in developing iPhone or Mac GUI application. All I want is

enter C programs using a text editor,
compile it ,
and get the output in a Console.
How can I do it ?

Thanks.

The version of GCC for mac comes with XCode. Install xcode, then call gcc form the terminal just like in Linux.
 

Hansr

macrumors 6502a
Apr 1, 2007
897
1
Or grab the GCC binaries from here:
http://hpc.sourceforge.net/

Then you can compile directly with text editor + terminal.

I recommend XCode thought just for easier (visual) debug + code sense (intellisense, what ever their calling it this week) which will generally speed coding.
 

willieva

macrumors 6502
Mar 12, 2010
274
0
Install xcode to get gcc

vi/emacs are already on your computer

It's just like any other unix computer with bash/csh
 

robvas

macrumors 68040
Mar 29, 2009
3,240
629
USA

Documents robert$ nano hello.c
Documents robert$ gcc hello.c
hello.c: In function ‘main’:
hello.c:4: warning: return type of ‘main’ is not ‘int’
Documents robert$ ./a.out

Welcome to Mac OS X
Documents robert$


If you type "gcc -o hello hello.c" it will make 'hello' the program, the default is 'a.out'

Nano is just a simple text editor (free alternative to pico, the pine editor)
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
Hi,

I have just come to Mac world from Linux world and I love my way around in Mac environment. I want to write and practice simple C programs in mac and I was searching for the tools I require. Most (All) of the resources in the web ask me to use XCode as IDE to do programming in C on Mac. XCode, for my purpose seems to be an overkill. I am in no way interested in developing iPhone or Mac GUI application. All I want is

enter C programs using a text editor,
compile it ,
and get the output in a Console.
How can I do it ?

Thanks.

Just one thing: If you have any programming questions and ask here for help, please state very very clearly that you are not using XCode. Lots of times people will ask what error message XCode gives, ask you to set a breakpoint somewhere and so on, and if you don't use XCode then this is all a waste of time. In particular I wouldn't want to waste my time giving help on a problem that is caused by some compiler options that would never have happened if you had started out with the XCode templates.

In other words: Go with the flow.
 

MorphingDragon

macrumors 603
Mar 27, 2009
5,160
6
The World Inbetween
Just one thing: If you have any programming questions and ask here for help, please state very very clearly that you are not using XCode. Lots of times people will ask what error message XCode gives, ask you to set a breakpoint somewhere and so on, and if you don't use XCode then this is all a waste of time. In particular I wouldn't want to waste my time giving help on a problem that is caused by some compiler options that would never have happened if you had started out with the XCode templates.

In other words: Go with the flow.

I have to disagree, going with the flow means to use Visual Studio for C++ and thats just not on. ;)

---

Xcode has a commandline app template, use it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.