Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com From: "Ralf Habacker" To: "Cygwin" Cc: "Mariusz Woloszyn" Subject: AW: exporting symbols from executable and linking shared objects question Date: Wed, 23 May 2001 16:33:20 +0200 Message-ID: <001b01c0e395$50a162c0$6e032bb7@BRAMSCHE> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-2" Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Importance: Normal Look at http://sourceforge.net/project/showfiles.php?group_id=27249 there is a misc package with an patched ld with this functionality. Perhaps you can use it Regards Ralf Habacker EMail: Ralf AT habacker DOT de Ralf DOT Habacker AT saght DOT tessag DOT com > -----Ursprüngliche Nachricht----- > Von: cygwin-owner AT sources DOT redhat DOT com > [mailto:cygwin-owner AT sources DOT redhat DOT com]Im Auftrag von Mariusz Woloszyn > Gesendet am: Mittwoch, 23. Mai 2001 15:51 > An: cygwin AT cygwin DOT com > Betreff: exporting symbols from executable and linking shared objects > question > > > Hi!! > > I'm new to the list, but I searched archives looking for a solution and > found nothing. > > I have TWO questions, but it's the same problem. > > First is -rdynamic swich for gcc. it's used to export symbols for shared > objects and the second is about linking shared objects (.dll) with symbols > declared as external. > > Let's see following code: > > ---main.c--- > #include > #include > > int c; > > main () { > > int (*foo)(); > void *handler = dlopen ("./foo.so", RTLD_LAZY|RTLD_GLOBAL); > if (!handler) { > fputs (dlerror(), stderr); > printf("\n"); > exit(1); > } > foo = dlsym(handler,"foo"); > > (*foo)(); > dlclose(handler); > } > ---main.c--- > > and following shared object source: > > ---foo.c--- > //extern int c; > > foo () { > printf("Fooo!\n"); > // printf("c=%i\n",c); > } > ---foo.c--- > > If I compile it under Unix or windows (under Win using attached shell > script -- refering to the documentation) everything is OK. But WHAT I have > to do to get it working with foo looking like this: > > ---foo.c--- > extern int c; > > foo () { > printf("Fooo!\n"); > printf("c=%i\n",c); > } > ---foo.c--- > > > Under Unix I used to compile main: > gcc main.c -o main -ldl -rdynamic > (to export symbols to dynamically dlopened shared objects), and foo: > gcc -shared foo.c -o foo.so > > First of all -rdynamic does not work under cygwin and moreover ld fails > linking shared objects with symbols declared as external. > > Any suggestions??? > > Regards, > > -- > Mariusz Wo³oszyn > Internet Security Specialist, Internet Partners > -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple