Friday, July 29, 2016

C Basics - The Setup for C

C is what is called a compiled language. This means that once you write your C program, you must run it through a C compiler to turn your program into an executable that the computer can run (execute). The C program is the human-readable form, while the executable that comes out of the compiler is the machine-readable and executable form.

To type your C program you need another program called Editor. Once the program has been typed it needs to be converted to machine language (0s and 1s) before the machine can execute it. To carry out this conversion we need another program called Compiler.

On compiling the program its machine language equivalent is stored as an EXE file on the disk. This file is called an executable file.

Steps in creating executable file:
  • Editing – Create/Modify program source code. It creates source file (*.c).
  • Compiling – Generate machine instructions. It creates object file (*.obj).
  • Linking – Link in libraries. It creates executable file (*.exe).
  • Executing – Run program.
The minimum software requirement to program in C is a text editor. A plain text Notepad Editor can be used but it does not offer any advanced capabilities such as code completion or debugging. There are many text editors the most popular are Notepad++ for Windows, Sublime Text, Vim and Emacs are also available cross-platform. These text editors come with syntax highlighting and line numbers, which makes code easier to read at a glance, and to spot syntax errors.

A compiler is a program that converts C code into executable machine code. Popular compiler includes:
Turbo C MS-DOS
Turbo C++ MS-DOS
Microsoft C MS-DOS
Visual C++ Windows
Borland C++ Windows
TCC Windows, Linux
Clang Windows, Linux, Unix
GNU C Compiler Linux, Unix
MinGW Windows

Many programmers prefer and recommend using an Integrated development environment (IDE) instead of a text editor. An IDE is a suite of programs that developers need, combined into one convenient package, usually with a graphical user interface. These programs include a text editor, linker, project management and sometimes bundled with a compiler and debugger. Popular IDE includes:
Eclipse CDT Windows, Linux
Netbeans Windows Linux
Anjuta Linux
Geany Windows, Linux
Little C Compiler Windows
Dev C++ Windows
Visual C++ Windows
CodeLite Windows, Linux
Code::Blocks Windows, Linux
Xcode Mac OS

GCC:
The most frequently used and free available compiler is the GNU C/C++ compiler. To check whether GCC is installed on your LINUX or UNIX system, enter the following command from the command line.

$ gcc –v

If you have GNU compiler installed on your machine, then it should print a message as follows −

Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-3) 


If GCC is not installed, then you will have to install it yourself using the detailed instructions available at http://gcc.gnu.org/install/

To install GCC on Windows, download MinGW from www.mingw.org. Add the bin subdirectory of your MinGW installation to your PATH environment variable, so that you can specify these tools on the windows command line by their simple names.



Related topics:
Intro of C   |   Overview of C   |   Features of C   |   Applications of C   |   Source Program in C   |   Program Startup and Termination in C   |   Program Structure in C   |   First Program in C   |   Must Know Terms in C

List of topics: C Programming

No comments:

Post a Comment