Mail Archives: cygwin/2000/10/10/21:09:10
Greetings,
I've read everything I could (including libtool, dlltool, gcc, ld
documentation, cygwin archives, and google and alltheweb searches),
and still haven't managed to make this work.
I want to export symbols from an executable, so that they can be used
to resolve symbols at run time from dlopen'ed libraries.
a.c : defines main and f1()
b.c : defines f2() which uses f1().
I want to end up with a.exe and b.dll. So that when a.c dlopens b.dll,
f1 is resolved.
Here's all the stuff I tried. I have tried RTLD_GLOBAL, RTLD_LAZY
and RTLD_NOw options.
1. Generate a library (liba.a) so that b.dll can be built using
dlltool with the exe name as the dll name.
2. Link b.c with -shared liba.a so that it resolves completely. b.c
does have a valid entry point.
3. Link a.c with -Wl,--export-dynamic so that all functions are
exported.
4. Run a.c, but dlopen() always fails.
I am using plain vanilla latest net install of cygwin. The only
change being the incorrect _cygwin_dll_entry prototype fix in
cygwin_dll.h
If f2 (in b.c below) is defined so: int f2(){return 1;}, then the
dlopen succeeds, so my build process seems to be mostly OK. Any help
would be much appreciated.
The commands I use are:
bash$ dlltool --dllname a.exe --input-def a.def --output-lib liba.a
bash$ gcc -Wl,--export-dynamic a.c -o a
bash$ gcc --shared b.c -o b.dll liba.a
bash$ ./a
Failed
Function not implemented
The files are :
---a.c----
#include <errno.h>
#include <dlfcn.h>
int f1(void)
{
return 1;
}
main()
{
void *p = dlopen(".\\b.dll", RTLD_NOW);
if (p == 0)
{
printf("Failed\n");
printf("%s\n", strerror(errno));
}
else
{
printf("Succeeded\n");
}
}
----b.c----
#include <cygwin/cygwin_dll.h>
extern int f1(void);
int f2 (void)
{
return f1();
}
DECLARE_CYGWIN_DLL(DllMain);
----a.def----
EXPORTS
f1
----------------
--
Regards
_______________________________________________________________________
Venkat Iyer venkat AT comit DOT com Phone: 1-408-988-2988 x 136
Comit Systems, Inc. The Contract Engineering Company www.comit.com
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
- Raw text -