Re: redirecting cout - is it possible with dynamically loaded DLL?
<johan.de.taeye@gmail.com> wrote in message
news:1185211139.472236.7830@q75g2000hsh.googlegroups.com...
Doug,
On 21 jul, 00:00, "Doug Harrison [MVP]" <d...@mvps.org> wrote:
If possible, link all the modules to the same CRT DLL, i.e. compile all
modules with /MD or /MDd (the IDE calls these the "Multithreaded DLL" and
"Multithreaded Debug DLL" in its option page for setting the "Runtime
Library"). Otherwise, they will have independent CRT state.
Sounds like they have different cout objects, because they are linking to
different CRTs.
Points right at the root of the problem, and I understood now what
happened !
I reviewed the compiler settings and I was using /MT (or /MTd in debug
build).
Switching the setting to /MD does indeed fix the problem, and the
modules also follows the redirection from the main program.
As a side-effect my application has now become dependent on the
MSVCP80 and MSVCR80 dll's. Which makes the distribution/installation
of the program more complicated. Hmmmm, will need to evaluate what to
do with this now...
Expecting the runtime library to be shared is only acceptable for components
of the same application, not reuse of libraries. In that case, why not
statically link all your code and don't use any DLLs -- solves the
distribution problem as well, without making multiple copies of the runtime.