From: Daemon Anastas <daemona@atomtechnology.com>
To: cygwin@sources.redhat.com
Subject: creating a dll with imports
Date: Fri, 22 Sep 2000 11:20:00 -0000 [thread overview]
Message-ID: <14795.41668.242229.342620@quark.local> (raw)
Hello all,
I am trying to create a dll which contains references to symbols
defined in the exe. This is very easy on solaris, linux or hpux
(dynamic loader scoping rules actually do most of the work).
I seem to be having a problem contriving a solution under windows
with the help cygwin. Anybody have a clue. Here is a simple example:
Here are the cygwin tool invocations and output
gcc -g -DLOOP_TEST -c m.c
gcc -g -DLOOP_TEST -c d.c
dlltool d.o --export-all-symbols --output-def d.def
dlltool m.o --export-all-symbols --exclude-symbols main --output-def m.def
dlltool m.def --def m.def -l m.lib -D m.exe
dllwrap --def d.def -o libd.dll d.o m.lib
gcc -o m.exe m.o
such that m.c contains main() and d.c is the source for the dll.
m.c and d.c follow. Any input is very much appreciated.
Daemon Anastas
/* d.c */
#include <stdlib.h>
int dfunc()
{
printf("in %s()\n", __func__);
#ifdef LOOP_TEST
foobar();
#endif /* LOOP_TEST */
}
/* m.c */
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
main()
{
char library[] = "./libd.dll";
char library_symbol[] = "dfunc";
void *libref;
int (*symref)();
fprintf(stderr, "DGA: PATH=%s\n", getenv("PATH"));
libref = dlopen(library, RTLD_LAZY);
if (libref == 0)
{
fprintf(stderr, "Unable to load library '%s'\n", library);
fprintf(stderr, " '%s'\n", dlerror());
return(1);
}
symref = dlsym(libref, library_symbol);
if (symref == 0)
{
fprintf(stderr, "Unable to find symbol '%s' in library '%s'\n", library_sy$ return(1);
}
printf("Going to call dynamically loaded symbol\n");
symref();
printf("DGA: PATH=%s\n", getenv("PATH"));
return(0);
}
#ifdef LOOP_TEST
int foobar()
{
printf("hi from foobar\n");
}
#endif /* LOOP_TEST */
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
reply other threads:[~2000-09-22 11:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=14795.41668.242229.342620@quark.local \
--to=daemona@atomtechnology.com \
--cc=cygwin@sources.redhat.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).