Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm 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 Date: Tue, 7 Dec 2004 08:46:35 -0500 (EST) From: Igor Pechtchanski Reply-To: cygwin AT cygwin DOT com To: robert AT fearthecow DOT net cc: cygwin AT cygwin DOT com Subject: Re: Suppressing linking errors with GCC/G++/ld under Cygwin In-Reply-To: <1d7bdfaa04120618524bec0978@mail.gmail.com> Message-ID: References: <1d7bdfaa04120618524bec0978 AT mail DOT gmail DOT com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 7 Dec 2004, Robert McLeay wrote: > Hi, > > (Sorry if this is OT, I'm trying to find out the Cygwin equivalent of > a GCC flag from other platforms.) > > I'm trying to compile a library for Qu-Prolog that will be linked at > run-time with program internals. As it will be linked at run time, I > would like to suppress all "undefined reference" errors somewhat > similarly to using "-undefined suppress" under Mac OS X. > > I'm using Cygwin, and here is the error message and the g++ line that I > am using. > > rob AT ches-laptop /cygdrive/c/rand2 > > $ g++ -shared -Wl,-soname,sym001476 $RAND2_LIB/rand.o -lc -o sym001476 > > ./rand.o(.text+0x24f): In function `iunif_interface': > / cygdrive/c/rand2/rand.cc:79: undefined reference to > `Thread::unify(Object*, Object*, bool)' > ./rand.o(.text+0x2ce): In function `iunif_interface': > / cygdrive/c/qp-cygwin-withicm/src/heap_qp.h:278: undefined reference to > `Heap::outOfSpace()' > collect2: ld returned 1 exit status > > Is there any way to suppress these errors and let it compile under > Cygwin the same way as using "g++ -flat_namespace -undefined suppress > -bundle" would under Mac OS X? This isn't OT, but I'm sorry to say that what you want to do is non-trivial due to the way Windows linking works. You can't have a DLL that's statically dependent on symbols from an executable. There are two ways around it. The first -- which I'm sure about, as I've used it myself -- is to extract the symbols from the executable into a helper DLL, and link your library DLL with the helper. The second, which is more iffy and will probably only work if the symbols are all functions, is to use dlopen()/dlsym() to get the address of the functions you need from the executable module. HTH, Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "The Sun will pass between the Earth and the Moon tonight for a total Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT -- 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/