josh247
josh247

Reputation: 175

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.

Upvotes: 3

Views: 853

Answers (2)

Thomas of the Scotts
Thomas of the Scotts

Reputation: 60

Two things:

  1. You can include partial libraries if your dependencies aren't very large in a subdirectory called lib and compile them there for compiling your application. It's fairly common in C++ to include a partial distribution of Boost in a lib folder if you depend on say, boost filesystem or boost thread or what have you.

  2. Tools such as CMake are phenomenal for easily constructing cross platform makefiles. They take care of all the work of finding libraries if they are installed and can even be written to download missing libraries. A solution such as this would keep your distribution code small and still get you everything you need. Personally I use CMake for all my applications because I hate writing makefiles and glob_recurse is so useful.

Upvotes: 0

Baruch
Baruch

Reputation: 21508

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.

Upvotes: 1

Related Questions