NAG Libraries: DLL versus Static

DLLs Versus Static: Who Should Get Your Vote?

If you develop applications in the Windows environment and are looking to make your life easier by using trusted components like NAG’s Library, you have probably had to consider the question: Should I use a "static" version of the NAG Library or the "DLL" version? In this note we’ll help decide which is best for you.

Since the NAG Fortran Library consists of over 1,200 component routines, the odds are small that any application you develop will use the majority of these routines. In any event, you are unlikely to use the entire library with any program. To meet the needs of customers operating in different circumstances, NAG provides its libraries in both a static version and a DLL/sharable version.

A Windows DLL is a lot like a shareable library in UNIX. DLL stands for "Dynamic Link Library". The word "dynamic" means that all of the components of the library are loaded at runtime, rather than being bound in the user's program itself. It also means that there's only one copy of the library components in memory, though they can be used by different programs. When someone builds a program using a static library, the library components exist in the program itself, and only the components needed by the program are included. To be precise, each program using routine X has its own copy of routine X. With a DLL, the NAG routine remains separate from the user's program.

The trade-off is generally between memory and speed. Using the DLL version, you incur the overhead of loading a significant portion of the library into memory, even if you need only a few routines. However, your programs are smaller since they do not contain the code for the routines. Also, multiple applications (or multiple users on a server) can use the same copy of the NAG Library. Of course, there is overhead in loading the DLLs and the memory they consume but, depending on the number of applications/users needing NAG Library routines, you may use less memory with the DLL version.

If you are creating an application using the NAG Library and need to distribute the application to many users for local execution, the static version of the NAG Library might be a good choice since the application will only contain the NAG routines needed. If you are developing an application for many desktop users or for a commercial application, NAG can create a tailored DLL library, containing just the routines you need, to be distributed with your application. Bear in mind that, if you distribute applications using NAG code to other machines, those machines need to be covered by a NAG software license.

In summary, if your application is destined for a few users or will be shared by many on a server, the DLL version of the NAG Library is a good choice. If your application will end up on many desktops, the static version of the NAG Library may be the best for you. For large distributions or commercial programs, talk to us about a tailored DLL library for your needs. In fact that is a good place to end. If you have questions about the best solution, please contact us.