Ken Alverson wrote:
I have one final question. I am using the threading dll, statically linked with the multithreaded runtime. My program (and the boost filesystem lib, which I statically link against) is also statically linked with the multithreaded runtime. This means there are two instances of the static runtime, one shared by my program and the filesystem, and one used by the threading library.
I'm unsure how this would behave. I have built the thread library as a lib for now (inspite of the problems when doing this).
Now, I know there are perils to having more than one copy of the runtime - notably if memory allocated in one runtime is freed by a different runtime. My question is whether it is safe to use the threading library linked in this way. I can't link against the dynamic runtime because I have to assume it is not present, but I can't link the threading library statically since it isn't designed to be built statically.
Could you do what regex has done, and build another version of the thread dll (which uses the dynamic RTL) and use #praga link statements in your code to decide which .lib to link against for the dll? Regex builds multiple libraries with different letters appended to the names for debug, release, single-threaded, multi-threaded etc, then there is a header file that picks out the correct by checking compiler settings, and inserts a #pragma link statement in the code to force the linker to look for the correct one. Cheers Russell