Search code examples
c++dllpackageportable-executableimport-libraries

Do I need to ship import libraries?


I have an application that uses the windows dbghelp.dll(mainly to read the PE file header of dlls). To work with the dll, I had to include dbghelp.lib (import library) in my linker options.

I do understand the functionality of import libraries. My question is , when I distribute my application to users, is the .lib file also packaged with it? As the .lib file is part of sdk from VS, I dont expect my users to have this file.

since dbghelp.dll is provided by default in windows, I expect my application to work correctly on any windows machine. Am I correct in assuming this?

Note: I do know about the various versions of dbghelp.dll being on different versions and how that can sometimes cause issues during runtime on different machines.


Solution

  • My question is , when I distribute my application to users, is the .lib file also packaged with it?

    No, you don't need to distribute the dbghelp.lib file to end users as it is only required to build your application (during the link phase).

    Note that the same also applies for developers if your application is open-source. They are expected to have the SDK to build your application, thus having already the dbghelp.lib file at disposition.

    OTOH, if your end product is a DLL, you might provide the *.lib file of your product so developers can link against your DLL.

    since dbghelp.dll is provided by default in windows, I expect my application to work correctly on any windows machine. Am I correct in assuming this?

    That's a good question and the answer is yes and no. dbghelp.dll is a little bit special as it is often upgraded but never as a part of system updates (except for bugs). So your application will work fine in most of the cases but if you use the latest version you cannot expect the end user to have it on its system. Thus your application might not work correctly.

    Quoting the MSDN:

    Although this DLL is included in all supported versions of Windows, it is rarely the most current version of DbgHelp available

    Thus you are free (unlike most system DLLs) to redistribute the dbghelp.dll file (along symbol server files, namely SymSrv.dll, and SrcSrv.dll which are not included on systems.):

    The redistribution policies for these included DLLs were specifically designed to make it as easy as possible for people to include these files in their own packages and releases.

    Note that you must distribute the files from the Debugging Tools For Windows (not the one from your system).