This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

AW: exporting symbols from executable and linking shared objects question


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@habacker.de
       Ralf.Habacker@saght.tessag.com

> -----Ursprüngliche Nachricht-----
> Von: cygwin-owner@sources.redhat.com
> [mailto:cygwin-owner@sources.redhat.com]Im Auftrag von Mariusz Woloszyn
> Gesendet am: Mittwoch, 23. Mai 2001 15:51
> An: cygwin@cygwin.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 <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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]