Board index » cppbuilder » create lib in c

create lib in c


2004-08-10 05:48:03 PM
cppbuilder114
i am a new user to this news group. plz could u help me as to how to ceate a
library in c
 
 

Re:create lib in c

Your question is ambiguous as there are many kinds of 'lib' and ways
to make them. Since the IDE has built in help for creating a library
you should need no help with that so I will assume that you are
working from the command line with Borland C++ and making a static
library, a library which contains code, and not a Windows' dynamic
linked library (a DLL) or an import library for a DLL.
First, nothing special need be done to create a library in C versus in
C++. C language source files have the extension .C and C++ ones the
extension .CPP When the compiler finishes with the source file it
creates an object file, a same-name file with an extension of .OBJ
which contains the compiled version of the code.
A library is a collection of object files placed into one file with an
added table telling of what object files are in it and what public
items (symbols) each of the object files provides.
The librarian utility is TLIB.EXE
Assuming that you have 1.obj, 2.obj and 3.obj and wish to create
MyLib.lib This command should do it:
tlib /C mylib.lib +1.obj +2.obj +3.obj
If you later wanted to add 4.obj to the library the command would be:
tlib /C mylib.lib +4.obj
If you have made a new version of 2.obj and wish to replace it then
give this command
tlib /C mylib.lib -+2.obj
This will create a listing of what is in the library
tlib /C mylib.lib , mylib.lst
do not overlook the comma in that command line
It is common for there to be so many object files to be added that the
command overflows the command line. You can get around that with a
response file. For example
tlib /C mylib.lib @respfile.txt
where respfile.txt contains the following
+1.obj &
+2.obj &
+3.obj &
+4.obj
Note that the & is a continuation character and it must be preceeded
by a space. The last line does not have & on it
. Ed
Quote
sachin jain wrote in message
news: XXXX@XXXXX.COM ...

i am a new user to this news group. plz could u help me as
to how to ceate a library in c