Building DLL that is linked against static libraries

Building DLL that is linked against static libraries

I saw this in the FAQ:

Can I build a VF DLL that is linked against the VF static libraries?
29-Oct-1997

We strongly recommend that you NOT do this as it can cause subtle and difficult to analyze application errors. If you build a DLL, always link against the shared libraries.

Can anyone elaborate on why I shouldn't do this? I create Fortran DLLs that are called using EXCEL VBA. A lot of the code in the DLL is the same across various projects so I placed these into a static library. Therefore, a programmer working on a new project only needs to modify the project specific code and link with the static library. Sounds like a reasonable thing to do.

I'm not an expert on the inner workings of DLLs, so I'd appreciate info that anyone can provide.

Thank you,
Kin Wong

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The warning is to not link to the Visual Fortran static run-time library. Your own static library is fine - just build it with the setting that it is to link to the DLL libraries. (/libs:dll). The reason for this is that if you link the static RTL into your DLL, you can end up with two or more copies of the RTL active in your application, which can cause subtle errors in I/O and memory allocation.

Steve

Steve - Intel Developer Support

Steve,

With an .exe/single DLL (to be loaded by a non CVF client) linked to the static rtl, how can you end up with two or more active copies of the rtl?

Thanks,
Gerry T.

If you KNOW that's the case, then it's probably safe to use the static VF RTL, though you might end up with two copies of the MSVC RTL if the EXE uses it.

I don't want to try to say that it's always safe if so-and-so conditions are met - you've got our recommendation and our reasoning - you take it from there.

Steve

Steve - Intel Developer Support

The recommendation is clear, its the reasoning that's ambiguous. Why does the Project..Settings..Fortran..Libraries..Use Run-Time Libraries default to Static?

--
Gerry T.

Leave a Comment

Please sign in to add a comment. Not a member? Join today