cURL / Mailing Lists / curl-library / Single Mail


Re: libcurl eas built whitout LIBSSH2

From: Stephen Collyer <>
Date: Wed, 23 Apr 2008 18:27:27 +0100

Brian Dessent wrote:
> Stephen Collyer wrote:

>> Right. However, a .lib can also be a static library, no ?
>> Is there a tool to tell me whether or not a given .lib is
>> an import or static library ?
> Yes, these .lib files (both static libraries and import libraries) have
> the same file format as an 'ar' archive -- in the GNU toolchain (i.e.
> MinGW/Cygwin) they are named as libcurl.a and libcurl.dll.a to make this
> explicit. You can tell an import library using 'nm', e.g.:
> $ if nm -AP libcurl.a | grep -q ' I '; then echo "import library"; else
> echo "static library"; fi
> static library

I'd already noticed that file reports the libcurl.lib as "current ar
archive", which had me pretty confused, but I guess this is because
it's a static library. (My nm crashes when I try to look at it, so I
can't run your test)

> I don't know what the MSVC equivalent is, probably dumpbin.

You're right. I've run this on the libcurl.lib in question and
it reports it as having multiple .idata sections, but also a .text,
.rdata and .data sections whereas a .lib that I know to be an import
library has only .idata sections. I think that implies that it must
be a static library, though I'm not sure what the .idata sections
are for in this case.

>> Right, that's useful to know to those of us who are hard-of-Windows.
>> Is it possible to generate an import library from a .def file and
>> a .dll ? It sounds like there should be all the required info
>> available.
> You can create an import lib from a .def file using 'dlltool' (GNU
> tools) or 'lib' (MSVC tools.) In fact you can link directly to a .dll
> without even needing an import lib if you're using the GNU toolchain.
> The DLL itself is not needed; the .def file lists all the exports of the
> DLL, that's its entire function. You can create a .def file from an
> existing .dll as well. The GNU toolchain has the 'pexports' command for
> this, I don't know what the MSVC equivalent is.

Brian, thanks for the info - you've cleared up my understanding of
what's going on here. I'm now pretty certain that Mike didn't
provide the import library, so I guess I'm going to have to
try to create it.

Steve Collyer
Netspinner Ltd
Received on 2008-04-23