From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3479 invoked by alias); 4 Sep 2003 12:59:51 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 3431 invoked from network); 4 Sep 2003 12:59:48 -0000 Received: from unknown (HELO moutng.kundenserver.de) (212.227.126.187) by sources.redhat.com with SMTP; 4 Sep 2003 12:59:48 -0000 Received: from [212.227.126.161] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 19utiG-0005h0-00 for cygwin@cygwin.com; Thu, 04 Sep 2003 14:59:48 +0200 Received: from [80.133.51.111] (helo=CNEISE) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 19utiE-0006U8-00 for cygwin@cygwin.com; Thu, 04 Sep 2003 14:59:46 +0200 From: "Christian Neise" To: Subject: AW: Create dll using gcc Date: Thu, 04 Sep 2003 12:59:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal Importance: Normal In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 X-SW-Source: 2003-09/txt/msg00281.txt.bz2 Hello, Igor, Thank you very much for your answer - it helped me a lot :-) Ciao, Christian. -----Ursprungliche Nachricht----- Von: Igor Pechtchanski [mailto:pechtcha@cs.nyu.edu] Gesendet: Dienstag, 2. September 2003 16:38 An: Christian Neise Cc: cygwin@cygwin.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 > > 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@cs.nyu.edu ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.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/