Easy Tutorial
❮ C Intro C Examples Reverse Sentence Recursion ❯

C Environment Setup

Local Environment Setup

If you want to set up a C language environment, you need to ensure that your computer has the following two software available: a text editor and a C compiler.

Text Editor

This will be used to type your program. Text editors include Windows Notepad, OS Edit command, Brief, Epsilon, EMACS, and vim/vi.

The names and versions of text editors may vary on different operating systems. For example, Notepad is commonly used on Windows operating systems, while vim/vi can be used on Linux/UNIX operating systems.

Files created by the editor are usually called source files and contain program source code. Source files for C programs typically use the .c extension.

Before you start programming, make sure you have a text editor and sufficient experience to write a computer program, save it in a file, compile it, and execute it.

C Compiler

The source code written in the source file is human-readable. It needs to be "compiled" into machine language so that the CPU can execute the program according to the given instructions.

The C language compiler is used to compile the source code into the final executable program. It is assumed that you already have a basic understanding of programming language compilers.

The most commonly used free compiler is the GNU C/C++ compiler. If you are using HP or Solaris, you can use the compiler available on your respective operating system.

The following sections will guide you on how to install the GNU C/C++ compiler on different operating systems. C/C++ is mentioned here primarily because the GNU gcc compiler is suitable for both C and C++ programming languages.

Installation on UNIX/Linux

If you are using Linux or UNIX, use the following command on the command line to check if GCC is installed on your system:

$ gcc -v

If the GNU compiler is already installed on your computer, you will see a message like this:

Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr .......
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)

If GCC is not installed, please follow the detailed instructions at http://gcc.gnu.org/install/ to install GCC.

This tutorial is written based on Linux, and all given examples have been compiled on a Cent OS Linux system.

Installation on Mac OS

If you are using Mac OS X, the quickest way to get GCC is to download the Xcode development environment from Apple's website and follow the installation instructions. Once Xcode is installed, you can use the GNU compiler.

Xcode is currently available for download from developer.apple.com/technologies/tools/.

Installation on Windows

To install GCC on Windows, you need to install MinGW. To install MinGW, visit the MinGW homepage at mingw-w64.org, go to the MinGW download page, and download the latest version of the MinGW installer, named in the format MinGW-<version>.exe.

When installing MinGW, you should at least install gcc-core, gcc-g++, binutils, and MinGW runtime, but usually, more other items are installed.

Add the bin subdirectory of your MinGW installation to your PATH environment variable so that you can specify these tools by their simple names in the command line.

When the installation is complete, you can run gcc, g++, ar, ranlib, dlltool, and other GNU tools from the Windows command line.

❮ C Intro C Examples Reverse Sentence Recursion ❯