Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is best practice for deploying an application as static or as dynamic build?

I am planning to release and deploy an application, written in C++ and wxWidgets. The wxWidgets-library is available as dll and as well as static library. Therefore, i have the option to deploy the application as dynamic built application or as static build.

Currently, i prefer the static-build option, because:

  • the executable is not too big ( < 20 MegaByte).
  • there are no dependencies to consider.
  • there is no installation required.

Question

Did i miss something very important?

like image 601
orbitcowboy Avatar asked May 18 '16 09:05

orbitcowboy


1 Answers

You should use dynamic linking when there is a good reason to use it and static linking otherwise. Some good reasons to use dynamic linking are:

  1. You're distributing binaries for a system which already has or, may have, wxWidgets libraries such as a number of Linux distributions, OS X (with Homebrew) etc. In this case it is strongly preferable to reuse the existing system libraries rather than using your own ones.
  2. You have several modules using wxWidgets: space saving from using dynamic linking may be quite significant here.
  3. You use wxWidgets from a DLL under MSW: in this case wxWidgets itself should also be linked as a DLL, otherwise you risk having problems if more than one instance of wxWidgets is loaded into the process address space.
  4. You plan on updating the installation of your application via network: in this case it may be nice to be able to update just a single DLL instead of a whole monolithic application.

If neither of these reasons apply, e.g. you just want to distribute a single program under MSW, static linking is simpler and so preferable.

A related note: if you do end up distributing wxWidgets DLLs, consider using a unique suffix for them instead of "custom" used by default, this will reduce the chances of confusion between your DLLs and some other version of wx.

like image 72
VZ. Avatar answered Oct 04 '22 18:10

VZ.