delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/06/20/13:14:16

X-Spam-Check-By: sourceware.org
Message-ID: <4679604E.2A40A3FE@dessent.net>
Date: Wed, 20 Jun 2007 10:13:50 -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: shared library - undefined symbols
References: <307299 DOT 34461 DOT qm AT web30801 DOT mail DOT mud DOT yahoo DOT com>
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

Dan O'Brien wrote:

> g++ -o build/unknown-pc-cygwin/debug/plugin.so -shared -Wl,--allow-shlib-undefined build/unknown-pc-cygwin/debug/.objs/plugin.o build/unknown-pc-cygwin/debug/.objs/NullFilter.o build/unknown-pc-cygwin/debug/.objs/NullFilterFactory.o

First of all, get rid of -Wl,--allow-shlib-undefined.  There is nothing
you can tell the linker that will change the fact that on PE systems,
all symbols must be defined at link-time, i.e. there can be no undefined
symbols in shared libraries.  This is not something that is up to the
linker, it's a basic fundamental property of the platform that we can't
change.

Is is possible to import symbols from the main .exe from a plugin, but
it requires that you declare them dllexport in the main .exe, and it
requires that you create an import lib for the main .exe, which you can
do during its link with -Wl,-out-implib,libgpm.a.  Then add -lgpm to the
link of the plugin.

This should work, but it's sometimes considered rather ugly because it
hardcodes the name of the executable into the plugin, just as if gpm.exe
was a regular library.  Thus the plugin cannot be used in a general
manner with any other .exe, and will fail to load if the .exe was
renamed.

The standard workaround for this is to move the symbols into their own
common .dll and import them from both the main .exe and from the module.

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