How to compile a .c file on my Mac?

How to compile a .c file on my Mac?

+66
c macos
Apr 08 '10 at 21:11
source share
8 answers

You will need to install Apple Developer Tools . Once you have done this, the easiest way is to either use the Xcode IDE or use gcc from the command line.

According to Apple, the latest version of Xcode (3.2.1) only works on Snow Leopard (10.6), so if you have an earlier version of OS X installed, you will need to use an older version of Xcode. Your Mac should have come with a developer DVD that will contain a version that should work on your system. In addition, older versions of the download are still available on the Apple Developer Tools site. Xcode 3.1.4 should run on Leopard (10.5).

+28
Apr 08 2018-10-18T00:
source share

You will need to get a compiler. The easiest way is probably to install the Xcode development environment from the CDs / DVDs that you have on your Mac, which will give you gcc. Then you should compile it as

 gcc -o mybinaryfile mysourcefile.c 
+37
Apr 08 '10 at 21:17
source share

For recording only nowadays,

for 2017!

1 - Just updated Xcode on your computer as usual,

2 - Open the terminal and

 $ xcode-select --install 

he will perform a short installation of a minute or two.

3 - Launch Xcode. "New" "Project" ... you need to select "Command Line Tool"

Note. Vaguely, this is on the macOS tab .

select this option

Select the language "C" on the next screen ...

enter image description here

4- You will be asked to save the project somewhere on your desktop. The name you give the project here is really just the name of the folder that will contain the project.

5 - You are golden! Now you can enjoy c with Mac and Xcode.

you are golden

+12
May 29 '17 at 15:59
source share

You can use gcc in the terminal by running gcc -c tat.c -o tst

however, it is not installed by default. You need to install the Xcode package from the installation disk for the tour or download from http://developer.apple.com

Here you can download the latest developer tools, including Xcode 3.1, 3.0, 2.5 ...

http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wo/5.1.17.2.1.3.3.1.0.1.1.0.3.3.3.3.1

+5
Apr 08 '10 at 21:15
source share

Use the gcc compiler. This assumes that you have the developer tools installed.

+2
Apr 08 2018-10-18T00:
source share

Ondrasej is the "most correct" here, IMO.
There are also gui-er ways to do this without resorting to Xcode. I like TryC.

Mac OS X includes developer tools, a development environment for creating Macintosh. However, if someone wants to learn programming using C, Xcode is too big and too complicated for beginners to write a small sample program. TryC is very suitable for beginners.

enter image description here

You do not need to run a huge Xcode application or enter unfamiliar commands in the terminal. Using TryC, you can write, compile and run C, C ++ and Ruby, like TextEdit. It is only available to compile one source file, but this is enough to try a sample program.

+2
Sep 15 2018-11-11T00:
source share

In 2017, this will be done:

 cc myfile.c 
+2
Aug 25 '17 at 2:02 on
source share
0
Apr 08 '10 at 21:14
source share



All Articles