As part of my research, I write a lot of Python and MATLAB code that never needs to be distributed to anyone else. Even if I need to distribute my software, Python and MATLAB, both being interpreted, make sharing it relatively simple.

Now I am writing some software in C++ that I'd like to distribute. I have a handle on how to compile the software on my own machine, but what I don't have an understanding of is what needs to be done in order to give other people the software.

First, more about my project: I'm writing some code to compute and display visualizations. The project is graph-based, and so I am using the LEMON graph library. I'm exploring VTK and OpenGL implementations for the purpose of displaying the visualization. I'd like to write Python and MATLAB bindings for users of those environments to be able to use my software, and I'd like to produce Windows and Linux versions (I haven't thought about OS X yet...).

So, let's take the LEMON graph library as an example. It is a bunch of headers along with a small shared object. On my development system, I compile the library with CMake and link it with my project.

Now say I want to give my software to someone running on Windows. I want them to be able to download an installer, click a button or two, and have everything taken care of. I don't want them to worry about installing the LEMON library, or OpenGL. They shouldn't have to knowingly compile anything. Is this possible?

I have a feeling it is, but I come up short when searching for references. I have a vague idea that if I compile a binary on Windows I should be able to distribute that binary to anyone running a Windows OS. But what about the libraries I use? I'm guessing I need to statically link them on Windows, and that will take care of the dependency issue there. But in the back of my mind I have read that statically linking is not good practice (or is this just on Linux?)

As you can tell, I'm somewhat lost. I'd appreciate a nudge in the right direction, and some references to read if you happen to know of any!

  • 6
    Got a piece of advice for you: start TRYING. Actually compile some package, go to another computer and try to run it there (use installers only after you know what to do). Rinse, repeat. Explore compiler settings, avoid using debug libraries for release, use dependency tracking. Commented Aug 22, 2013 at 4:52
  • @DeerHunter I can appreciate the empirical approach, and I certainly have spent a few hours experimenting and searching. That said, I'd like to know if it is even possible to package, say, VTK, with my software so that the user doesn't have to install it or any of its dependencies. Every project I have seen that uses VTK asks the user to install it as a prerequisite. Maybe that's my answer.
    – jme
    Commented Aug 22, 2013 at 5:27
  • 1
    jme, it is possible if you check the license and the license permits this. Bundled dependencies are supported in all major installer frameworks. Commented Aug 22, 2013 at 5:29
  • 1
    On Linux, dynamic linking is preferred, because the package management software ensures there is only one copy of each library in the system. But on Windows, just link statically as it does not have much of a usable package manager. Even on Linux I'd statically link stuff that is not in standard package repository, or in LSB for cross-distribution compatibility. Just make sure you are allowed to do so (LGPL stops on dynamic link boundary, so you may not statically link e.g. Qt in non-LGPL application).
    – Jan Hudec
    Commented Aug 22, 2013 at 6:44
  • 1
    @JanHudec on windows you can also just link dynamically and put all used dlls in the same directory as the exe
    – stijn
    Commented Aug 22, 2013 at 8:01

1 Answer 1


So long as the licence of the VTK libraries permits it, you might be able to write an NSIS Installer script (which will create a redistributable installer) that will install the VTK libraries in quiet mode. Quiet mode (if the VTK installer has this) will install the libraries without prompting the user for any input - this is how most video game installers work (required software is installed without prompting you to agree to the terms of use, or where to install it).

However, just blindly installing extra software might leave you in a precarious legal position. I'm not entirely sure on the legality of it, but I'd guess that you have to inform the user of all of the extra software you are about to install on their machine.

As an example, one of the installers I've scripted (for a product I work on) requires SQL Server 2005 to be installed alongside the binary. In the install script, if the user's machine doesn't have the required version of SQL server (or later) installed, it calls the MSI file for SQL Server 2005 (packaged within the NSIS installer) with the /q switch. This installs the SQL server with default settings, and all the user sees is the "installing SQL server 2005" prompt that get's thrown up whilst the MSI does it's work. We make a point of informing the user about this, and giving them the choice to install our software without it.

You might be able to create a make that will build all of your libraries for you, then call the NSIS script builder, but I'm not sure. I've not looked that far down the rabbit hole for NSIS, as we're not automating out installer builds.

Of course, you can replace NSIS with any other installer scripting environment. I've only used it here as an example, because I have a little experience with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.