delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/09/26/05:32:15

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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
Message-ID: <4337C029.5786F209@dessent.net>
Date: Mon, 26 Sep 2005 02:32:25 -0700
From: Brian Dessent <brian AT dessent DOT net>
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Visibility of compiler symbols between executables and DLLs
References: <dcb629180509260139f2440c1 AT mail DOT gmail DOT com> <279601c5c27a$cc315170$5304a8c0 AT chimaera>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com

Max Bowsher wrote:

> I'm fairly sure that it is impossible. Actually, it might be possible if
> there was a flag to convice GCC to add an import table to the built .exe,
> but last time I investigated that, there was no such flag. But even if that
> was possible, the .dll would need to explicitly link against the .exe that
> was to load it, for this method to work.

This does actually work, AFAIK.  You need to use __declspec(dllexport)
on the symbols in the .exe, and produce an import library
(-Wl,--out-implib) when building the .exe which is then used in linking
the .dll.  It hardcodes the name of the .exe in the .dll though, so it
also means that you cannot use the .dll as a general purpose library.

Refactoring out to a common .dll is much cleaner.  You can also design
the API so that you pass pointers to the symbols as arguments to
functions in the .dll.

The archives of this list (and the mingw list FWIW) have numerous
versions of this question, because it comes up all the time from people
that are used to the way linux shared libraries work.

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