public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk>
To: gnu-win32@cygnus.com
Subject: mingw32: .exe -> .a import libs for DLLs?
Date: Sat, 17 Jan 1998 11:14:00 -0000	[thread overview]
Message-ID: <x2ra66c3g4.fsf@blueberry.kubism.ku.dk> (raw)

Arrrgh. I've been messing around with dlltool and friends all day,
trying to get a DLL to modify a global variable with mingw32, or
rather Werner Koch's cross-development version of it. Basically, I
want to (various bits removed for brevity, so this won't actually run;
dl-routines lifted from Luke Tierney's web page at 
http://www.stat.umn.edu/~luke/xls/projects/dlbasics/dlbasics.html ):

-----------
dltest.c:

int zip = 0;
void baz(void);

main(int argc, char *argv[])
{
  void  *libb;
  void (*foo)(void), (*bar)(void);

  libb = dlopen("b.dll", RTLD_NOW);
  bar = dlsym(libb, barsym);
  printf("zip is @%x\n",&zip);
  printf("baz is @%x\n",&baz);

  bar();
  dlclose(libb);
}

void baz()
{
  printf("baz called; zip = %d\n", zip);
}
---------
b.c:

void bar()
{
  printf("incrementing zip @%x\n", &zip);
  zip++;
  printf("calling baz @%x\n", &baz);
  baz();
  printf("done with bar\n");
}
------------

OK, so I follow the instruction to make b.dll (relocatable, a.m. John
Cerney) and dltest.exe. To access baz and zip, I tried to use the
usual procedure for creating export and import libs for dltest and
linking them into dltest.exe and b.dll, respectively. This works, as
far as loading b.dll and invoking it, but the addresses of zip and baz
are not the same in the two modules, so the zip++ naturally generates
a GPF. Obviously, they aren't getting properly relocated. I think what
I need is a dltest.a with the load addresses hardcoded, but how do I
do that?

Apparently, the commercial compilers know how to do this (nudge,
nudge, know what I mean?) in each their different way.

There are some notes on Fergus's page on building DLL's with gnuwin32,
but quite honestly, I cannot make heads or tails of them...

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

             reply	other threads:[~1998-01-17 11:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-17 11:14 Peter Dalgaard BSA [this message]
1998-01-19 15:26 ` Fergus Henderson
1998-01-19 17:06   ` Peter Dalgaard BSA
1998-01-19 10:32 Colin Peters

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=x2ra66c3g4.fsf@blueberry.kubism.ku.dk \
    --to=p.dalgaard@biostat.ku.dk \
    --cc=gnu-win32@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).