Showing posts with label Linking C Program. Show all posts
Showing posts with label Linking C Program. Show all posts

Sunday, 4 March 2012

Preparation of C Program for Execution



Dear readers,
              In this lesson we tell you about the some necessary steps to prepare C program for execution..
SO FRIENDS LETS START LESSON
  • Some steps which are taken to prepare a C program for execution are :-
  1. Creating & Editing C Program
  2. saving C program
  3. Compiling C program
  4. Linking C program
  5. Loading C program
  6. Executing C program
  • Creating & Executing C program :-
                                                   The first step is to create and edit the source program in C. The C program is usually and edited in Turbo C editor.
  • Saving C program :-
After writing or editing the source program, it is saved on the disk as text file with an extension ".c".
  • Compiling C program :-
In this step, the source program is compiled. The source program is converted into machine code. The C compiler is used to translate  the C program source code into the machine code.
  • Linking C program :-
In this step, the Linker links object file produced by the compiler to many other library files.
 After linking the object code  to the libraries, an executable file with extension EXE is created.
  • Loading C program :-
                    In this step the loader loads the executable file from disk into memory for execution. The program must be loaded into memory for execution.

  • Executing C program :-
In this step, the program is executed on the computer. The CPU fetches instructions of program from memory one by one and takes action on them.


Monday, 20 February 2012

Linking C Program


Dear readers,
               In this post you will learn the method to link a C program....
SO FRIENDS LETS START LEARNING
  • Linking C program :-
               Linking is a process in which the object file produced by the compiler is linked to many other library files. This work is done by the Linker.
 The Linker is a program and is a part of compiler. After linking the object code to the libraries, an executable file with extension EXE is created.
For example :-
            If  source file name is "test.c", then executable file name will be "test.exe".
                      In Turbo C environment, program is linked as;
  • Select Link command from Compile menu on the menu bar.
 
In Turbo C IDE, compiling and linking can be performed together in one step. To do this, select Make command from Compile manu or press F9 key. The linker can also detect errors.
  • For Example :-
If the source code uses a library function that does bot exist, the linker generates an error. If there is any error in the source code, the Linker will not create the executable file.
 In this case, the errors are removed from the source code and source code is compiled again. The new object file is then linked to the libraries to create the executable file. The file directly dun on the computer.