Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Date: Tue, 08 Aug 2000 22:47:48 +0430 (GMT+04:30) From: jens AT uniweb DOT se Subject: Re: Problems using a DLL created with GNU from Microsoft VC++ To: cygwin AT sources DOT redhat DOT com Message-id: <465861255.965758668774.JavaMail.root@colin.uniweb.se> MIME-version: 1.0 X-Mailer: Sun(TM) Web Access 1.2 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7BIT 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 > #include > > 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 DOT Sandberg AT era DOT ericsson DOT se) > > > >-- >Want to unsubscribe from this list? >Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com > > -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com