X-Spam-Check-By: sourceware.org Message-ID: <4679604E.2A40A3FE@dessent.net> Date: Wed, 20 Jun 2007 10:13:50 -0700 From: Brian Dessent 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> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Reply-To: cygwin AT cygwin DOT com Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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/