X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_33,SPF_PASS X-Spam-Check-By: sourceware.org Message-ID: <4A727198.7010108@users.sourceforge.net> Date: Thu, 30 Jul 2009 23:22:48 -0500 From: "Yaakov (Cygwin/X)" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.1) Gecko/20090715 Thunderbird/3.0b3 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Creation of a shared module (gcc -shared) , undefined references References: <4A71A396 DOT 8060300 AT bull DOT net> In-Reply-To: <4A71A396.8060300@bull.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 On 30/07/2009 08:43, Martine Carannante wrote: > I try to port on CYGWIN an open source which runs correctly on Linux. > In this open source, a shared module (linked with option -shared) is > created and after it's loaded by the main program with lt_dlopen() > function. > > On CYGWIN, I have a problem when I create the module (gcc option > -shared). I have always some undefined references to functions which > belongs to the main program. On Linux it's not a problem, there are no > errors. As was already pointed out, unlike ELF shared objects, PE/COFF DLLs must have all symbols resolved at link time. In this situation, where plugins depend on symbols in an executable, there are a few workarounds: 1) Make everything in the main executable except for main() a shared library, then link both the program's main() and the plugins against that; 2) Build the main program first with these additional LDFLAGS: '-Wl,--export-all-symbols,--out-implib,libfoo.a'. Then build the plugins, adding to their LDFLAGS: '-Wl,/path/to/libfoo.a'. 3) If the package uses libtool and the number of symbols required by the DLLs is few, an alternative is to add '-Wl,--export-all-symbols' to the main executable LDFLAGS, and create a foo.def file with the following syntax: IMPORTS foo_symbol_1 = foo.exe.foo_symbol_1 foo_symbol_2 = foo.exe.foo_symbol_2 Then add '-export-symbols /path/to/foo.def' to the plugins' LDFLAGS. Making a patch using any of these solutions that could possibly be accepted upstream will take some more work, but at least you should be able to build it yourself. HTH, Yaakov -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple