X-Spam-Check-By: sourceware.org Date: Sat, 11 Feb 2006 00:59:43 -0500 (EST) From: Igor Peshansky Reply-To: cygwin AT cygwin DOT com To: skaller AT users DOT sourceforge DOT net cc: cygwin AT cygwin DOT com Subject: Re: help with dynamic linkage? In-Reply-To: <1139634710.8498.16.camel@rosella> Message-ID: References: <1139634710 DOT 8498 DOT 16 DOT camel AT rosella> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Unsubscribe: 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 Sat, 11 Feb 2006, skaller wrote: > hi, I'm having some problem getting dynamic linkage to work. > The linkage model is like this: > > mainline <----- load time ---- librtl.dll > ^ / > \ / > dlopen / > \ / > user.dll <----------------- > > gdb indicates the code is crashing in dlopen. LoadLibrary > doesn't appear to work either :) > > All the code is C++. It works on Linux, it works with > the option -mnocygwin, and it works with MSVC++. You mean "-mno-cygwin", right? > It *used* to work with Cygwin. The problem is almost > certainly just using the wrong linker switches. It would help if you told us what linker switches you're using. In fact, a small example program, buildable with a makefile into two DLLs and a main application, would be even more helpful. > The linkage technique is to follow Linux: no export libraries > are built, build time linkage is done directly against the > dll. This works fine for a simple C program. > > In order to build according to the above model, > there are 3 compilation steps, and 3 linkage steps. > However, the crash is unrelated to building the user.dll, > since it occurs whenever mainline calls dlopen, even with > a garbage name. Then wouldn't you be able to reproduce it with only one DLL and one main application? Can we see a small complete example that shows the problem? > I have cygwin installed on 2 comps and get the same result. > > I have tried two methods: generate and link against export file > librtl.dll.a, and just linkagainst librtl.dll. Both methods > fail. Warnings like: > > Info: resolving vtable for XXXby linking to __imp__XXX (auto-import) > > occur when linking the executable. Those are informational. You can either ignore them, or give the "-Wl,--enable-auto-import" flag to the linker to quiet them. > Switches: -O3 -fomit-frame-pointer --inline > > Hosts: > * AMD64 running XP pro SP1 > * AMD64x2 running XP64 > > Cygwin: latest setup provides. Umm, setup can provide quite a few versions ranging from ancient to latest, depending on your mirror. Why not follow the guidelines at and attach (as an uncompressed text attachment) the output of "cygcheck -svr"? > Any hints what is causing the problem or how to fix it? Not until we have enough information to allow us to reproduce the problem. FWIW, I was unable to reproduce this with a trivial instance of your scheme above and default linker options. One quick question: how are you invoking functions from user.dll, are you getting the right function pointer, and are you taking care of C++ name mangling when loading symbols from the DLL? Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu | igor AT watson DOT ibm DOT com ZZZzz /,`.-'`' -. ;-;;,_ Igor Peshansky, Ph.D. (name changed!) |,4- ) )-,_. ,\ ( `'-' old name: Igor Pechtchanski '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte." "But no -- you are no fool; you call yourself a fool, there's proof enough in that!" -- Rostand, "Cyrano de Bergerac" -- 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/