Search code examples
c++dependenciescross-platformdynamic-library

Dynamic Libraries, dependencies and distribution?


Before I started developing any more c++ projects, I wanted to establish a good multiplatform environment and use some basic form of revisioning (rsync). To do this I learn't how to construct makefiles (with uname variables) and also started using mingw inside of a cygwin environment on windows. This was so that I could hopefully develop on all platforms in a homogeneous manner under a unix like shell.

What I don't understand is the standard working practice for distributing compiled programs that have dependencies on dynamic libraries. For example when I compile with mingw on windows, I need to add the most basic of libraries (libstdc++-6.dll) to the executable directory for it to run. Just for the standard library I need to add three .dll's and even then dependency walker shows countless more although it appears to run.

Surely every library needs to be included as it would be impossible to guarantee the end user would have it locally?

If this is the case, is it common to just include the dynamic libraries within the same directory as the executable?

I also read that .so files act as an import library as well as a dynamic library. Would these then also need to be included in the executable directory?

Cmake is useful for such things and I presume I'll end up using it. This said I thought it would be helpful for me to learn how to accomplish cross platform development without it first.


Solution

  • No, you do not need to include every .dll mentioned in dependency walker. Most of them, including the standard library, are guaranteed by Microsoft/Posix/etc. to be available with the OS.

    A good rule of thumb is that if you had to install it on your computer, you probably have to install it on the users computer.