delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/03/18/06:57:10

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <47DFADEA.A4E4C21B@dessent.net>
Date: Tue, 18 Mar 2008 04:56:26 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: DLL into .a
References: <47DFA7F9 DOT 5040402 AT dq DOT fct DOT unl DOT pt>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Paulo Mota wrote:

> Is there a tool to convert a DLL (which has no API Windows calls) into a
> lib.a or lib.la ?

That is not possible.  A DLL is fully linked code.  A static library
(libfoo.a) is unlinked code.  Linking is a one-way process, it removes
information that cannot be recovered.

A file named as libfoo.la is a libtool library, and is just a text file
of a few lines that describes the options relevant when linking with
that library.  It alone is useless, it is just metadata.

> If not, then say that I have a lib file named libmetis.a
> To make the executable I  would add the following
> "-L$HOME/<rest of the path> -lmetis"
> If I have WinMetis.dll, would there be an equivalent command?

Just add "WinMetis.dll" to the link command line like any other file to
be included in the link.

You can also create an import library, but that is not necessary unless
you need to do symbol aliasing or symbol renaming.  This is often
necessary when mixing libraries of different compilers due to
differences in stdcall name mangling, i.e. you need to remove the @nn
decorations.

You might be confusing a static library with an import library, as they
both end in .a and have the same file format but they are totally
different things.  An import library (libfoo.dll.a, foo.lib, or
occasionally libfoo.a) does not contain any code, but rather just a list
of what the actual library (DLL) exports.  It is used by the linker when
linking to the DLL, but the GNU linker can also link directly to a DLL
without the need for an import library -- again as long as you don't
need to do any symbol renaming/aliasing.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019