Software Archive
Read-only legacy content
17061 Discussions

Building DLL that is linked against static libraries

kwong107
Beginner
769 Views
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
0 Kudos
4 Replies
Steven_L_Intel1
Employee
769 Views
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
0 Kudos
Intel_C_Intel
Employee
769 Views
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.
0 Kudos
Steven_L_Intel1
Employee
769 Views
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
0 Kudos
Intel_C_Intel
Employee
769 Views
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.
0 Kudos
Reply