Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how does one create a .lib?

Status
Not open for further replies.

darthAndy

Programmer
Feb 28, 2003
6
0
0
US
Hi,
I need to build a .lib in c. I'm using borland turbo c. The library will contain files with functions that interface with a com port. I'm going to run it on a WIN 98 platform. I guess turbo c outputs to a 16 bit dos terminal emulator. Thats what i'll be using.

How would I create the .lib file to include in an application. i.e.
#include "my_com_lib.???"

I think a library is made from several .obj files(which are created from compiled source code, right?)
So what are the basic steps in creating a .lib?

Thanks,
Andy


 
Well you can download 'ar' for windows. You can search for Unix Utils on Windows.

Hope this helps.
 
Hi,
Are you talking SHARED DLL's or Static DLLS?

on windows, .LIB files are CODELESS. They only contain the necessary information to allow your program to link against exported functions from a shared DLL.

Build yourself a .DLL and the linker should automatically build the .LIB.

you then link against the .LIB

-l myfunc

will locate myfuncs.lib at link time and tell the loader to find.....

myfuncs.dll

at run time.

 
If you work in C++ mode you can use
#pragma comment(lib, "yourlib.lib")

Ion Filipski
1c.bmp
 
Thank you, I'm just creating a static library for c. I just use the linker to access the functions in my library?
 
link does not access functions. It changes function names to function addresses(links) and put missing functions implementations in local executable or shared object/dll.

Ion Filipski
1c.bmp
 
I have never used a STATIC DLL on Windows but I suspect so since that is what it does on UNIX. The linker will copy the code from your static library into the executable so that you only have to ship your executable.

With a shared DLL, the executable just has REFERENCES to the external functions and you must ship both the executable and the shared library as the code for your functions really live in the shared library.

the ultimate test of whether to go with a STATIC library or a SHARED library is whether you want BIG executables and whether your functions change often.

If your functions change frequently your are frequently recompiling your static Library. Then you must RELINK all of your executables which link against the library and reinstall all of those executables.

This is because each executable has its own private copy of the code for that function which has to be changed every time you change that function.


With a shared library you just relink it and reinstall it. The executables automatically see the new version of the functions the next time they run.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top