Mail Archives: cygwin/1997/11/18/16:24:40
Hi,
I'm tring to use a foreign DLL in my program, it's the ldap32.dll
from U of Michigan.
I'v got a ldap32.def file from their source distribution of ldap-3.3,
and I created my libldap.a with:
dlltool --dllname ldap32.dll --def ldap32.def --output-lib libldap.a -k
The original .def file is for MSVC++, so CODE and DATA contain
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
Those values aren't understood by dlltool.
Someone has posted a message on dlltool who indicates the acceptable .def
format, according to the message, I'v changed them to
CODE READ WRITE EXECUTE SHARED
DATA READ WRITE EXECUTE SHARED
I linked my simple program with it by
gcc -Ic:\ldap\inckit -L\ldap\lib main.cc -lldap
All works well. But the program craches at the very begining.
Examining it by gdb, I get :
(gdb) r
Starting program: //D/try/a.exe
10000000://D/try/ldap32.dll
776c0000:/WINNT/System32/WSOCK32.dll
[failed reading symbols from DLL]
"/WINNT/System32/WS2_32.dll": error reading line numbers
779e0000:/WINNT/system32/MSVCRT.dll
[failed reading symbols from DLL]
"/WINNT/system32/KERNEL32.dll": error reading line numbers
77e70000:/WINNT/system32/USER32.dll
77ed0000:/WINNT/system32/GDI32.dll
[failed reading symbols from DLL]
"/WINNT/system32/ADVAPI32.dll": error reading line numbers
77e10000:/WINNT/system32/RPCRT4.dll
[failed reading symbols from DLL]
"/WINNT/System32/WS2HELP.dll": error reading line numbers
warning: LDR: Automatic DLL Relocation in a.exe
warning: LDR: Dll cygwin.dll base 10000000 relocated due to collision with
D:\try\ldap32.dll
2520000:/GNUWIN32/B18/H-I386-CYGWIN32/BIN/cygwin.dll
Program received signal SIGSEGV, Segmentation fault.
0x252bac6 in fhandler_console::is_console ()
(gdb)
My main.cc is very simple :
#include <stdio.h>
// undef _WIN32 because otherwise there are a lot of __declspec( dllexport )
// not understood by gcc
#undef _WIN32
#include <lber.h>
#include <ldap.h>
int
main()
{
char* string = ldap_err2string(0);
printf("foo");
return 0;
}
It seems that this is a DLL loading problem, ldap32.dll been loaded at fixed
address 10000000, causing cygwin.dll loaded at the end (in normal case, it's
loaded the first at 10000000), so when is_console() is called, cygwin.dll is
not yet initialized (I learned this in "Porting Unix Applications to Windows
NT" by Andrew Lowe).
So the questions are:
1) Do I have well understood the book ?
2) If so, how do you resolve the problem ? How do you make the ldap32.dll
loaded
at a different fixed address or at a variable address ?
3) if not, what's the real reason ?
Thanks a lot.
Zixiong WANG
zi AT spidernet DOT tm DOT fr
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -