Start Coding C on your Mac

Posted:
in Mac Software edited January 2014
Here is a short tut on how to start coding C on your Mac. I went through some trouble to find this info so, I thought it might help some people if I made a tutorial on what to do. (I did this on a Intel Core Duo OSX 10.4 Mac, so for other Macs it might be slightly different) This is my first tutorial so bear with me!



1. To tell if you have already done this, go to terminal and type "gcc" and hit enter. If it says something about no input files that means you have this already installed. If not, go to step 2.



2. Get your OSX install CDs, and take CD one and put it in your disc drive.



3. Wait a for a window to pop up that says, "Mac OS X Install Disc 1". Then click the Xcode Tools folder, you might need to scroll down to see it.



4. Click XcodeTools.mpkg and follow through on the installation (Its straightfoward).



5. Go to your Hard-Drive and check to see if their is a Developer folder. If you are intrested in using Xcode to develope applications go to step 6, otherwise skip it and go to step 7.



6. Click the Developer folder and then the Applications folder and you should see your Xcode and Interface Builder icons. I havn't used Xcode so, im not going to say anything else about it since I don't want to give false information.



7. Go to Terminal and type "gcc" and hit enter. If it tells you something about no input files, you did everything right. If not, try installing the Developer Tools again or ask for help from someone who knows a lot about Macs.



8. Make a file called helloworld.c on your desktop, with the following code:

#include <stdio.h>



main()

{

printf("Hello World\

");

return(0);

}




9. Go to Terminal and type the following command:

gcc /Users/YOURNAME/Desktop/helloworld.c -o helloworld

If you get an error, check to make sure you copied the code correctly.



10. Type ./helloworld into Terminal and it should output "Hello World!".



Congradulations, you just got C working on your Mac! Post any questions here and I will try to help. If you want to learn more about the gcc command, check here.



EDIT:

For some cocoa/c tutorials check out: http://forums.appleinsider.com/showp...72&postcount=6

Comments

Sign In or Register to comment.