Subject: AW: exporting symbols from executable and linking shared objects question
From: "Ralf Habacker" <[email-masked]>
To: "Cygwin" <[email-masked]>
Cc: "Mariusz Woloszyn" <[email-masked]>
Date: Wed, 23 May 2001 16:33:20 +0200

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: [email-masked]
       [email-masked]

> -----Ursprüngliche Nachricht-----
> Von: [email-masked]
> [mailto:[email-masked]]Im Auftrag von Mariusz Woloszyn
> Gesendet am: Mittwoch, 23. Mai 2001 15:51
> An: [email-masked]
> 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 <dlfcn.h>
> #include <stdio.h>
>
> 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