"cout" and "cerr" won't work after cygwin1.dll init from VC++

Matthew Woehlke mw_triad@users.sourceforge.net
Tue Dec 19 21:05:00 GMT 2006

Francisco J. Royo Santas wrote:
> I have a VC++ program that uses a Cygwin-compiled DLL. I can init cygwin1.dll
> but, after doing this, cout and cerr stop working. cout << "Message" << endl
> does not appear on the screen. I do not know exactly what happens here. The
> program is:

/me repeats Dave's comment

> cout << "Before" << endl;   // Appears
> HMODULE cygwinDll = LoadLibrary("cygwin1.dll");
> void (*init)() = (void (__cdecl *)(void)) GetProcAddress(cygwinDll,
> "cygwin_dll_init");
> init();
> cout << "After" << endl;    // Does nor appear
> What is going on here?? What do I have to do to have cout and cerr back
> normally??

Does it work if you /don't/ use cout before cygwin_dll_init()?

My guess would be "don't expect to be able to use cout/cerr before /and/ 
after calling cygwin_dll_init()". This just "feels" like something that 
would not work, nor should you probably be doing it. I would think that 
calling cygwin_dll_init() needs to be /the very first thing you do/. In 
fact, doing anything with stdin/stdout/stderr (i.e. stdio too) before 
and after is probably a bad idea unless you know what you are doing.

This message is non-smoking

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/

More information about the Cygwin mailing list