Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > C in OSX - Newbie Question

C in OSX - Newbie Question
Thread Tools
Junior Member
Join Date: Sep 2002
Location: The Alamo City
Status: Offline
Reply With Quote
May 11, 2003, 01:26 PM
 
Okay, here's the situation.

Is there a way for me to write, compile and execute C code in the Terminal environment?

Will I need any special compilers or will OSX know what I'm doing?

I konw I can install Linux, but I realy don't like it all that much, no specific reasoning behind it, I just don't feel very comfortable in it.

I usually write my code when I ssh into the school's Sun system and just go at it, but there are times when I am not near a network connection that I can work on my programs.

Hope I haven't confused anyone.
     
Moderator
Join Date: Sep 2000
Location: Irvine, CA
Status: Offline
Reply With Quote
May 11, 2003, 01:31 PM
 
Sure, it is easy as pie. Just launch emacs or your favorite text editor in the Terminal and type away. Save it as a plain text file with the extension .c and do a cc file_name.c in the terminal and at the end, do ./a.out.
{{{ mindwaves }}}
     
Senior User
Join Date: Dec 2001
Status: Offline
Reply With Quote
May 11, 2003, 01:34 PM
 
Code:
cc file.c -o program chmod u+x program ./program
[Edit: mindwaves beat me to it...]
"Think Different. Like The Rest Of Us."

iBook G4/1.2GHz | 1.25GB | 60GB | Mac OS X 10.4.2
Athlon XP 2500+/1.83GHz | 1GB PC3200 | 120GB | Windows XP
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
May 11, 2003, 01:50 PM
 
You will need to make sure you have Developer Tools installed.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
May 11, 2003, 03:35 PM
 
You'll need to install the Developer Tools. Other than that, though, it's almost identical to the same process on Linux. The major difference is that Apple's compiler is called cc, even though it's really gcc (they may even have a softlink so that you can call it as gcc in more recent versions).
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
Junior Member
Join Date: Sep 2002
Location: The Alamo City
Status: Offline
Reply With Quote
May 11, 2003, 04:00 PM
 
Thanks for the responses.

I tried the basic Hello World program to see if i got any results.

When I cc'd it, it gave me
cc: Command not found
So I'm thinking I don't have Developer Tool installed, which leads me to my next question.

Is Developer Tools a thrid party software, or should I have a disk for it (which means I'll have to hunt my drawer of important disks (there's a lot of disks in there!)

Thanks again.
     
Senior User
Join Date: Dec 2001
Status: Offline
Reply With Quote
May 11, 2003, 04:28 PM
 
Depends on what kind of Mac you've got. If a developer tools CD didn't come with your Mac, check in /Applications/Installers. If it isn't in there either, you can always download a copy for free from http://connect.apple.com/ (it's about 140 MB, IIRC).
"Think Different. Like The Rest Of Us."

iBook G4/1.2GHz | 1.25GB | 60GB | Mac OS X 10.4.2
Athlon XP 2500+/1.83GHz | 1GB PC3200 | 120GB | Windows XP
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
May 11, 2003, 04:33 PM
 
It's most definitely Apple... You get it in the box with OS X on a separate CD, if you buy a new computer it's in /Applications/Installers -- just make sure you have the December 2002 ones. You can always get the latest version at connect.apple.com (free registration required, must be >18 for no good reason).

This really is a question you'd have been able to find an answer to if you'd looked, methinks.
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
May 11, 2003, 04:49 PM
 
Originally posted by Angus_D:
must be >18 for no good reason
I think it's because NDAs aren't binding on minors in the US. That's what I've heard, anyway.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Junior Member
Join Date: Sep 2002
Location: The Alamo City
Status: Offline
Reply With Quote
May 11, 2003, 06:33 PM
 
Originally posted by Angus_D:
...This really is a question you'd have been able to find an answer to if you'd looked, methinks.
You're probably right, but I did do a search. I probably searched for the wrong information, which is the only reason I started the thread.

For some reason, I can't seem to use common words or phrases when doing a search. For instance, when I was searching for info on this subject, I did a search for "ANSI C compilers". I got a lot of hits (probably matching for ANSI, C and compilers).

I can never do a decent search for some reason.
     
Mac Elite
Join Date: Jun 2001
Location: Dundee, Scotland
Status: Offline
Reply With Quote
May 11, 2003, 06:35 PM
 
Originally posted by Chuckit:
I think it's because NDAs aren't binding on minors in the US. That's what I've heard, anyway.
*cough*

Grandma, your eggs are ready!..

     
Mac Elite
Join Date: May 2001
Location: Up north
Status: Offline
Reply With Quote
May 11, 2003, 08:50 PM
 
Originally posted by Angus_D:
This really is a question you'd have been able to find an answer to if you'd looked, methinks.
I just about bought OS X again, when I already had it installed on my computer (it came with OS X preloaded, with the CDs and all, but no developer CD), just so that I could get the Developer CD. Just about wasted $120 CDN.

Then, when I was at the store with the box in my hand, one of the guys recognized me, and aksed me why I was buying 10.0 again, when I already had it, and I am like.. to get the developer tools, and he is like.. you can download them, and I am like.. I am an idiot! thanks!

Does it really matter if he just asks here his questions? I for one don't mind answering them, even if they can be looked up.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:32 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2