From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21883 invoked by alias); 2 Sep 2003 14:38:19 -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 21853 invoked from network); 2 Sep 2003 14:38:16 -0000 Received: from unknown (HELO slinky.cs.nyu.edu) (128.122.20.14) by sources.redhat.com with SMTP; 2 Sep 2003 14:38:16 -0000 Received: from slinky.cs.nyu.edu (localhost [127.0.0.1]) by slinky.cs.nyu.edu (8.12.9+Sun/8.12.9) with ESMTP id h82Ec2mL008070; Tue, 2 Sep 2003 10:38:02 -0400 (EDT) Received: from localhost (pechtcha@localhost) by slinky.cs.nyu.edu (8.12.9+Sun/8.12.2/Submit) with ESMTP id h82Ec2Sn008067; Tue, 2 Sep 2003 10:38:02 -0400 (EDT) X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs Date: Tue, 02 Sep 2003 14:38:00 -0000 From: Igor Pechtchanski Reply-To: cygwin@cygwin.com To: Christian Neise cc: cygwin@cygwin.com Subject: Re: Create dll using gcc In-Reply-To: <1dq8lvg41amn969pckkf1gou2t4b3lh1l3@4ax.com> Message-ID: References: <1dq8lvg41amn969pckkf1gou2t4b3lh1l3@4ax.com> Importance: Normal MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2003-09/txt/msg00133.txt.bz2 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/