delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/07/06/06:15:41

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Date: Thu, 6 Jul 2000 11:20:31 +0200 (CEST)
From: Farkas Zsolt <seen AT philoslabs DOT com>
To: Andrej Borsenkow <Andrej DOT Borsenkow AT mow DOT siemens DOT ru>
cc: cygwin AT sourceware DOT cygnus DOT com
Subject: Re: Sorry, resent RE: Accessing exported variables in DLL with dlsym().
In-Reply-To: <000501bfe729$8e656bb0$21c9ca95@mow.siemens.ru>
Message-ID: <Pine.LNX.3.96.1000706112025.8221D-100000@bagoy.philoslabs.com>
MIME-Version: 1.0



[SEEN]

Philos Laboratories, game development - http://www.philoslabs.com
On Thu, 6 Jul 2000, Andrej Borsenkow wrote:

> 
> (Sorry, I clicked wong button)
> 
> >
> > I am trying to port a program that opens dynamic library with
> > dlopen() and looks up symbol with dlsym(). This works for
> > function reference but not for variable. The porgram is:
> >
> > main.c:
> >
> > #include <dlfcn.h>
> > #include <stdio.h>
> >
> > main() {
> >     int (*foo)(void);
> >     void *libfoo;
> >
> >     libfoo = dlopen ("libfoo.dll", 0);
> >     foo = dlsym (libfoo, "foo");
> >     foo();
> > }
> >
> > foo.c:
> >
> > #include <stdio.h>
> > #include <dlfcn.h>
> >
> > __declspec (dllexport) extern foo (void);
> >
> > foo() {
> >     char *bar;
> >     void *libbar;
> >
> >     libbar = dlopen ("libbar.dll", 0);
> >     bar = dlsym (libbar, "bar");
> >     puts (bar);
> > }
> 
> ... continued ...
> 
> bar.c:
> 
> __declspec (dllexport) char *bar = "Hi! I am bar.";
> 
> Compiled with:
> 
> gcc -c main.c foo.c bar.c
> dllwrap --output-exp libfoo.exp --output-lib libfoo.a  --output-def
> libfoo.def --dllname libfool --export-all-symbols foo.o
> dllwrap --output-exp libbar.exp --output-lib libbar.a  --output-def
> libbar.def --dllname libbar.dll --export-all-symbols bar.o
> gcc -o main main.o
> 
> Unfortunately, this program prints nothing (that is, bar appears to be
> found - but porbably points to wrong location).  IF I bind foo.o with
> libbar.a (and declare bar in foo.c as dllimport) I get correct result.
> The foo() in main() is correctly found.
> 
> TIA
> 
> -andrej
> 
> 
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
> 


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


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