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]

Re: Problems using a DLL created with GNU from Microsoft VC++


 One reason may be the calling convention. That may
corrupt the stack. But it also could be that since
MSVC++ and CYGWIN don't share the memorymanager, or
do they. That could be the problem. And is most
likly in this situation. Do you compile with
-mno-cygwin or do you use unix/gnu/posix functions
in cygwin?

 Jens Yllman

>I am trying to use a DLL created with cygwin g++ from an application created with Microsoft Visual C++. The reason is that I have C-code (huge) that is created for GNU and would like to use it in an application that requires Microsoft Visual C++.
>
>This is what I have done:
> - I started with the example described in http://sources.redhat.com/cygwin/building-reloc-dlls.txt.
>
> - I changed the main-file to load the DLL:
>	// Main file to try linking with a DLL under GNUwin32
>	#include <windows.h>
>	#include <stdio.h>
>
>	typedef int (*doit)(int);
>	typedef int (*doittoo)(int);
>
>	int
>	main()
>	{
>	   HINSTANCE hinstLib;
>	   doit      doitPROC;
>	   doittoo   doittooPROC;
>	   int       x;
>
>	   printf("main3.c\n");
>
>	   //--- LOAD LIB ---
>	   hinstLib = LoadLibrary("fooB.dll");
>	   if (hinstLib == NULL) {
>	      printf("Error loading DLL!\n");
>	      exit(0);
>	      }
>
>	   //--- LOCATE FUNCTIONS ---
>	   doitPROC = (doit)GetProcAddress(hinstLib,"doit__Fi");
>	   if (doitPROC == NULL) {
>	      printf("Can't locate doit()!\n");
>	      exit(0);
>	      }
>	   doittooPROC = (doittoo)GetProcAddress(hinstLib,"doittoo__Fi");
>	   if (doittooPROC == NULL) {
>	      printf("Can't locate doittoo()!\n");
>	      exit(0);
>	      }
>
>	   x = (doitPROC)(5);
>	   printf("doit(5) returns %d\n",x);
>
>	   x = (doittooPROC)(5);
>	   printf("doittoo(5) returns %d\n",x);
>
>	}
>
> - Compiled the code above with g++ main3.c -o main3.exe.  This works fine! Same result as before.
>
> - Compiled the code with Microsoft Visual C++ (unchanged). It compiles OK but it doesn't work. The message "Unhandled exception in main3.exe (NTDLL.DLL): 0xC000005: Access Violation." shows up. The Call Stack looks like this:
>	NTDLL! 77f6cde6()
>	NTDLL! 77f67506()
>	CYGWIN1! 6101edff()
>	CYGWIN1! 61047a6e()
>	CYGWIN1! 61077304()
>	CYGWIN1! 610774bb()
>	CYGWIN1! 61073560()
>	CYGWIN1! 6106f684()
>	FOOB! 1000102b()
>	main() line 38 + 7 bytes
>	mainCRTStartup() line 206 + 25 bytes
>	KERNEL32! 77f1ba3c()
>
>I am running cygwin (latest release, I made a fresh install this morning) with Windows NT 4. Any suggestions?
>
>/ Kenneth Sandberg  (Kenneth.Sandberg@era.ericsson.se)
>
>
>
>--
>Want to unsubscribe from this list?
>Send a message to cygwin-unsubscribe@sourceware.cygnus.com
>
>

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


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