-2

I'm creating an API to make it easier to find specifications about your system (CPU, GPU, etc.) using C++. This API will be distributed using GitHub.

In this scenario, which type of library should I use: Static or DLL (Dynamic)? Also, what are the pros and cons of each?

  • 6
    Both. Leave the choice up to the user of your library. – harmic Oct 24 '16 at 23:24
  • 1
    Possible duplicate of [When to use dynamic vs. static libraries](http://stackoverflow.com/q/140061/3425536) – Emil Laine Oct 24 '16 at 23:27
  • Agree with harmic. However, I should say that if the size of the library is relatively small, say less than 1 MB, maybe static would be a good idea. However, it is a good approach to leave the decision to the user. – macroland Oct 24 '16 at 23:28
  • static library cannot be called by c# etc. only other c++ code – pm100 Oct 24 '16 at 23:36
  • 1
    @pm100: C++/CLI can statically link against a C++ library, and provide a mixed-mode assembly for consumption by C#. – IInspectable Oct 24 '16 at 23:49

1 Answers1

0

It depends on a few things, but like in the previous comments, you can leave the choice to the user.

A DLL is easier to integrate since the user just has to do a LoadLibrary() to start using it.

The problem with the DLL is that if you compiled it without using the default libraries as static and if you don't provide the redistributables, the user will get frustrated because of SxS problems. It may just so happen that there may not be any issues with SxS but you never know.

If you give out the lib file, it is possible that some compilation options may conflict with yours, unless you only use vanilla options.

All in all, at the end of the day, both options are viable and similar. Just depends on how the user wants to use your API.

E.T
  • 1,095
  • 1
  • 10
  • 19