The most common practice in a large application development is using library
files for separate modules.
In general, large applications consist with many sub modules, in which many modules
created by third party vendors, comes in compiled format.
So generally we have to include these precompiled modules in our application.
In turbo C there are precompiled library files which contains function(and class definition if we are using turbo c++)definitions.
So in this tutorial I am discussing about using library files in a c program.
As we know that library files contains function definitions, so we have to create
a header file having function declarations of functions contained by library file.
So following is a simple example of using and creating library files in turbo C.
1. Create a file named Myfunc.c in turbo C and save it on any location you
want(in my example I used c:\lib),Now write following code in it.
#include <stdio.h >
2. Go to Options>Appliction... and click on Library button. This will set
output to Library file.
3. Now click on Compile>Build all. This will create Myfunc.LIB where you
saved Myfunc.c(in my example lib file is created on c:\lib\Myfunc.LIB)
4. Now create new file named Myfunc.h where you saved Myfunc.c file.
Now Write declaration of fun function in it.
Now this is the time to use your Library file.
5. First create a new C source file named Myapp.c where you saved other files
(in my example location is c:\lib) and write following code in it.
Now the final steps are following.
6. Now we are creating project in turbo C to include Lib File.
First Go to Project > Open Project... .Now enter the name of your project
whatever you want with the .prj extension (i have entered mypr.prj).
7. Now Add 3 files Myfunc.h, Myfunc.LIB and Myapp.c by go to Project > Add item...
8. Go to Options > Application... and click on Standard button.
9. Now Go to Compile > Build all... and run by Go to run Or press Ctrl+f9 .
You should see the output which will be "Hello Rahul."