This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

problem building dll


Hello,

I am experimenting with cygwin and attempting
to build a dll.  The following is my build
script:
gcc -g -c dll_main.c
gcc -g -c main.c
gcc -s -Wl,--base-file,testdll.base -o testdll.dll dll_main.o 
-Wl,-e,_lib_main@12
dlltool --base-file testdll.base --def testdll.def --output-exp testdll.exp 
--dllname testdll.dll
gcc -s -Wl,--base-file,testdll.base,testdll.exp -o testdll.dll dll_main.o 
-Wl,-e,_lib_main@12
dlltool --base-file testdll.base --def testdll.def --output-exp testdll.exp 
--dllname testdll.dll
gcc -Wl,testdll.exp -o testdll.dll dll_main.o -Wl,-e,_lib_main@12
dlltool --def testdll.def --dllname testdll.dll --output-lib testdll.a
gcc -o doit.exe main.o testdll.a


When I run the doit.exe executable I get the following
error:
      0 [main] doit 267 handle_exceptions: Exception: 
STATUS_ACCESS_VIOLATION
  92622 [main] doit 267 stackdump: Dumping stack trace to doit.exe.stackdump

I am trying to figure out what I am doing wrong, I
am pretty sure that I am following the directions
listed on the Cygwin site for building a DLL.

The following is my dll_main.c and testdll.def files:
//dll_main.c
#include <windows.h>
static int tester = 0;
int WINAPI lib_main(HANDLE h, DWORD reason, void *unused)
{
   tester = 5;
   return 1;
}

int main (int argc, char ** argv)
{
   return 0;
}

int dummy_function(char *tempBuffer)
{
   tempBuffer[0] = 'A';
   tempBuffer[1] = 'B';
   tempBuffer[2] = 'C';
   tempBuffer[3] = 0;
   lstrcpy(tempBuffer, "Hi Ma");
   return tester;
}

;testdll.def
LIBRARY testdll
EXPORTS
	dummy_function

When I run things through gdb it looks like everything
is dying on the call to lstrcpy.  Any external function
appears to crash my program (printf, strcpy, strcat ...).

Any help would be greatly appreciated.

Thanks,
--Craig
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]