Mail Archives: cygwin/2000/12/18/18:35:15
I'm having trouble with dll's that I build with gcc and dlltool. Any
time I try do do anything useful within a dll function, such as call
new or call any Win32 API, I get an access violation. Does anyone see
what I'm doing wrong? Below I provide mydll.cpp, mydll.def, myprog.c,
and build.bat. I'm using gcc version 2.95.2-5 19991024 (cygwin experimental)
Ultimately I intend to build an inproc COM server.
Thanks in advance for your help.
Greg Clinton
greg DOT clinton AT wonderware DOT com
------------------------------mydll.cpp------------------------------
#include <windows.h>
int main()
{
return 0;
}
extern "C" int WINAPI
mydll_init(HANDLE h, DWORD reason, void *foo)
{
return 1;
}
extern "C" int WINAPI
calc()
{
int *p = new int;
delete p;
return 34;
}
------------------------------mydll.def------------------------------
LIBRARY
EXPORTS
mydll_init
calc
--------------------------------myprog.c------------------------------
#include <windows.h>
typedef int (WINAPI *CalcProc)();
int main()
{
int i;
HMODULE hModule = LoadLibrary("mydll.dll");
CalcProc calc = (CalcProc) GetProcAddress(hModule, "calc");
i = calc();
FreeLibrary(hModule);
return i;
}
------------------------------build.bat------------------------------
set path=%path%;c:\cygwin\bin
set include=c:\cygwin\usr\include;
gcc -c myprog.c
gcc -c mydll.cpp
gcc -s -Wl,--base-file,mydll.base -o mydll.dll mydll.o -Wl,-e,_mydll_init AT 12
dlltool --base-file mydll.base --def mydll.def --output-exp mydll.exp
--dllname mydll.dll
gcc -s -Wl,--base-file,mydll.base,mydll.exp -o mydll.dll mydll.o
-Wl,-e,_mydll_init AT 12
dlltool --base-file mydll.base --def mydll.def --output-exp mydll.exp
--dllname mydll.dll
gcc -Wl,mydll.exp -o mydll.dll mydll.o -Wl,-e,_mydll_init AT 12
gcc -o myprog myprog.o
myprog.exe
-----------------------myprog.exe.stackdump-----------------------------
Exception: STATUS_ACCESS_VIOLATION at eip=6E677963
eax=6E677963 ebx=140D1074 ecx=0240FF08 edx=77FCD348 esi=6107C0E8
edi=00000000
ebp=0240F75C esp=0240FBF8 program=C:\temp\MyDll\myprog.exe
cs=001B ds=0023 es=0023 fs=003B gs=0000 ss=0023
Stack trace:
Frame Function Args
0240F75C 6E677963 (00000000, 00000000, 00000000, 00000000)
0240FC04 6E677963 (140D1074, 6107C0E8, 00000000, 0240FCF4)
0240FD24 140D1209 (00000004, 00000000, 00000000, 00000004)
0240FD54 140D1084 (00000004, 0240FDA0, 61040551, 00000004)
0240FD84 00401091 (00000001, 0A011218, 0A010008, FFFFFFFE)
0240FF10 610038AD (00000000, 03EEDEE4, 8046A640, 87F00280)
0240FF40 61003A8D (00401054, 03EEDEE4, 8340BAC0, 8049F5BE)
0240FF60 61003ACC (00000000, 00000000, 8340BC50, 00000005)
0240FF90 004010FF (00401054, FFFFFFFF, 80430B27, 00000000)
0240FFC0 0040103D (03EEDEE4, 0000064A, 7FFDF000, 03EEDC7C)
0240FFF0 77E87903 (00401000, 00000000, 000000C8, 00000100)
End of stack trace
--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -