cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl eas built whitout LIBSSH2

From: Brian Dessent <brian_at_dessent.net>
Date: Wed, 23 Apr 2008 09:14:01 -0700

Stephen Collyer wrote:

> OK, but AFAICS, by default, VS expects foo.lib to be an import library
> for foo.dll.

That's just not true at all. The name of the DLL is encoded into the
import library; the filename is totally irrelevant. For example, the
name of the import lib in the other curl binary packages is e.g.
libcurl_imp.lib or libcurldll.lib. You can name it whatever you want,
it doesn't matter.

> 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 don't know what the MSVC equivalent is, probably dumpbin.

> 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
Received on 2008-04-23