answersLogoWhite

0


Best Answer

The first step is to install the XCode developer tools that comes with OSX. You can do this by looking on your OSX install disc. There should be a folder for optional installs, and a package for XCode. This will automatically install gcc, a C compiler, on your machine. Next, find the Console in the Utilities folder. It opens a UNIX shell. Move to the directory that your c file is in (you can find more information about UNIX elsewhere if you need to). Let's say your C file is named myfile.c. To compile it, type: gcc myfile.c This will compile your program, and name the compiled program a.out. To run it, type: ./a.out I hope that helps. Brina

User Avatar

Wiki User

16y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

In Linux you can use the gcc [Gross C Compiler] compiler for compiling a C program. The file will be compiled and if no errors object file will be created, which can be executed by giving typing './a.out' in the current path. You can also specify a name to the output file. If you specify a name, after compilation a new file will be generated in the name you have specified, with a '.o' extention

For more information on gcc, type

'man gcc' or 'gcc --help' in the shell prompt.

AnswerIn Windows, you will need a compiler/builder like Microsoft Visual C++ Express or Dev-C++, both of which can be downloaded free of charge on the internet. Once you have this set up, open the project in the appropriate program (for help on this see the program's help files), and choose the Build option (or similar) from the menus at the top of the program's window. The Windows executable file (with file extension .exe) will most likely be in the same folder as the project provided there were no errors.

Double click it in Windows Explorer, and it will execute. If it's a command line program, the output may dissappear too quickly to be visible. In this case, press Windows+R to bring up the Run dialog. Type in 'cmd' (no quotes), and the Command Prompt should appear. navigate to the correct directory using 'CD ..' to go up a directory and 'CD [directoryname]' to go into a directory. From there, type the executable file's filename and hit Enter. The program should run.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

The exact syntax will vary depending on the compiler you're using.

Using GCC as an example:

gcc -o MyProgram.exe MyProgram.c

MyProgram.exe

Executing the first command above will take a program stored in MyProgram.c and compile it to MyProgram.exe. The second command will run the program.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Xcode and Eclipse are popular choices for developing Mac programs. Compilation is usually achieved with a modified version of the GNU Compiler Collection.

Note that you need both a compiler and a linker to create an executable. Compilation is the process of converting source code into object files. Linking is the process of linking those object files and the required libraries to generate the actual machine code. Although separate processes, most IDEs will perform both with a single command.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you compile and run C programs on the Macintosh?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you compile and run C plus plus programs on the Macintosh?

Use Xcode. See related links below.


What is a quick way to use Visual Studio.Net to compile and run a C?

To compile and run a C# program in Visual Studio.NET, open the program file in Visual Studio. Then, click on the "Build" menu and select "Build Solution" to compile the program. Once compiled successfully, press F5 or click on the "Debug" menu and select "Start Debugging" to run the program.


Can you run programs compiled with Turbo C on Linux?

Turbo C cannot compile native Linux binaries, only programs for MS-DOS. MS-DOS applications can be run on Linux through a variety of methods, including DOSEMU, DOSBox, QEMU, Bochs, and VirtualBox.


Why the programs of C and java are compiled before execution?

Because the source programs just do not run. Full stop.You have to1) compile them to an executable (C)2) use a program that interprets them (script languages, eg. sh, perl, php)3) mix the two: half-compile them into something that can be interpreted by another program (source -> javac.exe -> bytecode -> java.exe)


What are the steps in c plus plus?

Code, compile, link, run.


How many compilers are there to compile a C program?

There are many C compilers. In modern usage, the most common ones are Microsoft Visual C++ (which can also compile C programs) and GCC (GNU Compiler Collecttion, originally GNU C Compiler).


CAn you work in c or c plus plus without editor?

You can compile, link and execute programs without text-editor.


Can you access c language in dos and unix?

You can write, compile and execute C-programs in both DOS and Unix, if that's what you meant.


What is statement terminator in c language?

The compiler demands it: your programs wouldn't compile without them.


Why wont your C plus plus programs compile?

C++ programs won't compile if they contain compiler errors. The compiler will tell you precisely where the error is, and the type of error, unless the error is in a macro. The compiler cannot see macro definitions because they are inline expanded prior to compilation.


What are the disadvantages of lengthier c plus plus computer programs?

The source files take a longer time to compile, and reading and maintaining such programs is harder.


Can c be used on dos- operating system or xenix operating system?

Yes. There are C compilers for MS-DOS and for Xenix. Santa Cruz Operation OpenServer can compile programs to run on Xenix. See http://williambader.com/museum/dell/xenixhistory.html