If your application makes C run-time library calls and also calls functions contained in a DLL that makes C run-time library calls, note the following. If the executable and the DLL are both linked with one of the statically linked C run-time libraries(LIBC.LIB or LIBCMT.LIB), the executable and the DLL will have separate copies of all C run-time functions and global variables. This means that C run-time data cannot be shared between the executable and the DLL.
To avoid this problem, link the executable and the DLL with CRTDLL.LIB. This allows both the executable and the DLL to use the common set of functions and data contained in CRTDLL.LIB. C run-time data such as stream handles can then be shared by both the executable and the DLL.