[Distutils] Question about DOS/Windows static libs

James C. Ahlstrom jim@interet.com
Thu, 09 Mar 2000 09:40:51 -0500


Greg Ward wrote:
> 
> No no, I'm talking about *building* a library, not about using one.

Oh, sorry.

> Under Unix, it goes like this:
> 
>   cc -c foo1.c foo2.c foo3.c     # create *.o
>   ar -cr libfoo.a foo1.o foo2.o foo3.o
> 
> and with MSVC++'s command-line interface, I gather it's something
> sorta-kinda-vaguely like this:
> 
>   cl /c /Tcfoo1.c /Fofoo1.obj  # repeat three times
>   link foo1.obj foo2.obj foo3.obj /OUT:foo.lib

Well, no.  AFAIK "link" can create only executables or DLL's, not
libraries.  Note that, despite the name, a Dynamic Link Library is
very much like an executable and not much like a Unix static lib.

To create libraries under Windows, use the lib program:
    lib.exe /OUT:libfoo.lib foo1.obj foo2.obj foo3.obj 

Only the Windows "Great Unwashed" pay attention to this.  Normal
Windows people use the development environment.  In particular this
makes it easy to use lengthy lists of *.obj's instead of libraries.

JimA