This is the mail archive of the
mailing list for the Cygwin project.
Re: linking with non-cygwin dll
- From: Igor Pechtchanski <pechtcha at cs dot nyu dot edu>
- To: vikramshrowty at fastmail dot fm
- Cc: cygwin at cygwin dot com
- Date: Wed, 30 Jul 2003 21:03:26 -0400 (EDT)
- Subject: Re: linking with non-cygwin dll
- Reply-to: cygwin at cygwin dot com
On Wed, 30 Jul 2003 firstname.lastname@example.org wrote:
> I had posted a query earlier about a cygwin program linking
> with a non-cygwin dll. Based on the very helpful responses and some googling
> around, I learnt that this is possible. But...
> heres a main.c that links with cygwin1.dll
> int main(void)
> where test_dll is in a dll compiled with -mno-cygwin and is defined
> like this...
> __declspec(dllexport) __stdcall void test_dll(void)
> printf("MSFT %d\n",i);
> This works perfectly. But, notice the fflush. If this is removed,
> "MSFT" doesnt get printf'ed. I assuming that this is because the
> stdout buffer in the microsoft c-library isnt getting flushed
> automatically at program exit.
> Any ideas on why?? ..and how to remedy this??
Well, gcc links the Cygwin executable with its own C runtime. MSVCRT is
another C runtime. So, when you call the DLL, you have 2 C runtimes
competing for the same output stream. This can't be good (in fact, the
results are unspecified, IIRC). Thus, the simple remedy is: don't do
that. Either only use one runtime for output (whichever one), or fflush
|\ _,,,---,,_ email@example.com
ZZZzz /,`.-'`' -. ;-;;,_ firstname.lastname@example.org
|,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