delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/09/04/09:00:10

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Christian Neise" <neise AT dc-systeme DOT de>
To: <cygwin AT cygwin DOT com>
Subject: AW: Create dll using gcc
Date: Thu, 4 Sep 2003 14:59:46 +0200
Message-ID: <B9463A8BF1D12241909CA2FA744044E6066A0B@dcs-server.dc-systeme.de>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
Importance: Normal
In-Reply-To: <B9463A8BF1D12241909CA2FA744044E61440FC@dcs-server.dc-systeme.de>
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200

Hello, Igor,

Thank you very much for your answer - it helped me a lot :-)

Ciao, Christian.

-----Ursprungliche Nachricht-----
Von: Igor Pechtchanski [mailto:pechtcha AT cs DOT nyu DOT edu] 
Gesendet: Dienstag, 2. September 2003 16:38
An: Christian Neise
Cc: cygwin AT cygwin DOT com
Betreff: Re: Create dll using gcc


On Tue, 2 Sep 2003, Christian Neise wrote:

> Hello,
>
> i am trying to build a dll using cygwin and gcc. The dll will be used 
> by a delpi application.
>
> The dll works fine. But when allocating memory
> (e.g.: char *c = new char) the programm crashes.
>
> When compiling the dll with visual c++ 6.0 SP5 the dll works fine - 
> even if allocating memory.
>
> Any hints?
>
> Best regards,
>
> Christian Neise
>
> P.S.:
>
> I createdthe dll the following way:
> gcc  -c dll_test.cpp -o debug/dll_test.o
> gcc   -shared -o debug/dll_test.dll \
> -L/usr/lib \
> -Wl,--export-all-symbols \
> -Wl,--enable-auto-import \
> -Wl,--whole-archive debug/dll_test.o \
> -L/usr/lib \
> -Wl,--no-whole-archive -lc -lstdc++
>
>
> testdll.h:
>
> #include <string>
>
>  extern "C" {
>       __declspec( dllexport ) BOOL APIENTRY DllMain( HANDLE hModule,
>                             DWORD  ul_reason_for_call,
>                             LPVOID lpReserved
>          );
>  }
>
>
>
>
> testdll.cpp:
>
> #include "dll_test.h"
>
> BOOL APIENTRY DllMain( HANDLE hModule,
>                        DWORD  ul_reason_for_call,
>                        LPVOID lpReserved
>                                          )
> {
>     switch (ul_reason_for_call)
>         {
>                 case DLL_PROCESS_ATTACH:
>                 case DLL_THREAD_ATTACH:
>                 case DLL_THREAD_DETACH:
>                 case DLL_PROCESS_DETACH:
>                         break;
>     }
>     return TRUE;
> }

The DLL you created will require cygwin1.dll as its C runtime library.
The Delphi application most likely uses MSVCRT.DLL as it's C runtime.
It's not a good idea to mix the two runtimes (in fact, that's the most
likely reason for the crashes).  If you want to use your DLL with
Delphi, you could compile it using MinGW (by passing the "-mno-cygwin"
option to gcc), but you won't get full POSIX emulation that way.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his
route to the bathroom is a major career booster."  -- Patrick Naughton


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019