* creating a dll with imports
@ 2000-09-22 11:20 Daemon Anastas
0 siblings, 0 replies; only message in thread
From: Daemon Anastas @ 2000-09-22 11:20 UTC (permalink / raw)
To: cygwin
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2000-09-22 11:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-22 11:20 creating a dll with imports Daemon Anastas
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).