iostreams from within a static lib  
Author Message
Anjo Gasa





PostPosted: Visual C++ General, iostreams from within a static lib Top

What is the best way to have iostreams output (std::cout) from within a static lib be routed to a console I have managed front-end that calls a unmanaged static lib. Since the front-end has no console to begin with, I am using AllocConsole() to spawn one. Calls to std::cout from the managed code then appear on the console, however calls to std::cout in the unmanaged code do not appear.

If I then move the AllocConsole() call to the unmanaged code (again, which is linked into the managed code as a static lib), still calls to std::cout do not appear on the spawned console.


Anjo


Visual C++16  
 
 
Mike Danes





PostPosted: Visual C++ General, iostreams from within a static lib Top

The best thing do in this case is to make your application have a console in the first place. You can do this by changing the subsystem from WINDOWS to CONSOLE (see Project Properties\Configuration Properties\Linker\System\SubSystem).

If you whish to use AllocConsole then you may need to read this KB article. Just calling AllocConsole is not enough:

http://support.microsoft.com/kb/105305/en-us