delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/05/23/10:10:16

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
X-Authentication-Warning: dzyngiel.ipartners.pl: woloszyn owned process doing -bs
Date: Wed, 23 May 2001 15:50:42 +0200 (EEST)
From: Mariusz Woloszyn <cygwin AT clubbing DOT pl>
X-Sender: woloszyn AT dzyngiel DOT ipartners DOT pl
To: cygwin AT cygwin DOT com
Subject: exporting symbols from executable and linking shared objects question
Message-ID: <Pine.LNX.4.04.10105231531290.2874-101000@dzyngiel.ipartners.pl>
MIME-Version: 1.0

--429728448-1438512500-990625842=:2874
Content-Type: TEXT/PLAIN; charset=ISO-8859-2
Content-Transfer-Encoding: 8BIT


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

--429728448-1438512500-990625842=:2874
Content-Type: APPLICATION/x-sh; name="ll.sh"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine DOT LNX DOT 4 DOT 04 DOT 10105231550420 DOT 2874 AT dzyngiel DOT ipartners DOT pl>
Content-Description: 
Content-Disposition: attachment; filename="ll.sh"

DQojISAvYmluL3NoDQojICBFeGFtcGxlIFNjcmlwdCB0byBjb21waWxlIGFu
ZCBsaW5rIGEgcmVsb2NhdGFibGUgRExMDQojICAgIEZpbGVzIHRoYXQgbWFr
ZSB1cCB0aGUgRExMID0gJGZvby5jICBpbml0LmNjIGZpeHVwLmMuDQojICAg
ICAgICAoaW5pdC5jYyBhbmQgZml4dXAuYyBhcmUgaG91c2VrZWVwaW5nIHJv
dXRpbmVzIG5lZWRlZCBmb3IgdGhlIERMTC4gVGhlIGFjdHVhbA0KIyAgICAg
ICAgICAgICAgICAgICAgICBsaWJyYXJ5IHJvdXRpbmVzIGFyZSBpbiAkZm9v
LmMgYW5kICkNCiMgKioqRmlsbCBpbiB5b3VyIHBhdGggdG8gbGliY3lnd2lu
LmEgaGVyZSAod2l0aCBubyB0cmFpbGluZyBzbGFzaCkqKioNCkxJQlBBVEg9
L2xpYg0KDQplY2hvICJDb21waWxpbmciIGBiYXNlbmFtZSAkMSAuY2AiLmRs
bCINCg0KZm9vPSJgYmFzZW5hbWUgJDEgLmNgIg0KDQplY2hvICRmb28NCg0K
IyBDb21waWxlIHNvdXJjZSBmaWxlczoNCmdjYyAtYyAkZm9vLmMNCmdjYyAt
YyBpbml0LmNjDQpnY2MgLWMgZml4dXAuYw0KDQojIE1ha2Ug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lICRmb28uZGxsIC0tZGVmICRmb28uZGVmIC0t
b3V0cHV0LWxpYiAkZm9vLmENCg0KIyBMaW5raW5nIHdpdGggbWFpbg0KI2dj
YyBtYWluLmMgJGZvby5hIC1vIG1haW4uZXhlDQoNCg==

--429728448-1438512500-990625842=:2874
Content-Type: text/plain; charset=us-ascii

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple
--429728448-1438512500-990625842=:2874--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019