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

View: New views
5 Messages — Rating Filter:   Alert me  

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

by Francisco J. Royo Santas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello

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:

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??

Thanks and G'bye
Francisco J. Royo Santas


--
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/


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

by Dave Korn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 19 December 2006 20:09, 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:
>
> 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

  No, that is not the program, that is a not-very-useful non-compiling
snippet.

> What is going on here?? What do I have to do to have cout and cerr back
> normally??

  You probably ignored step 1.

http://cygwin.com/faq/faq.programming.html#faq.programming.msvs-mingw


    cheers,
      DaveK
--
Can't think of a witty .sigline today....


--
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/


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

by Bugzilla from mw_triad@users.sourceforge.net :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.

--
Matthew
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/


Parent Message unknown Re: "cout" and "cerr" won't work after cygwin1.dll init from VC++

by Francisco J. Royo Santas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I compiled the "cygload" package (it is supposed to be the way to load
cygwin1.dll and have the 4K scratch space) under MSVC and generated
msvc-cygload.exe. The execution result is:

Connecting to cygwin...
Warning!  Stack base is 00140000.  padding ends at 0013FFC0.  Delta is 64.  Stac
k variables could be overwritten!
Loading cygwin1.dll...
Initializing cygwin...

There should be more information after the last line (I wrote lines that should
appear and they do not). I DO need to use cout and cerr because the application
using cygwin1.dll and my own dll depending on cywing is a command-prompt
application.

How can I write to the command-prompt??

Thanks and G'Bye

Quoting Matthew Woehlke:

>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.


--
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/


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

by Anton Mellit :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Francisco J. Royo Santas wrote:
Hello

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:

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??

Thanks and G'bye
Francisco J. Royo Santas


--
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/
Actually I had the same problem. I am trying to write a GP/PARI - package for Python for Windows. GP/PARI is a software for numerical computation which uses cygwin. After loading cygwin python stopped to produce any output. The cure is to add "tty" parameter to the CYGWIN environment variable.

Anton