How to package C ++ dependencies on linux

I am developing a C ++ program on Ubuntu 16.04 using cmake, compiling with g ++ 5 and clang ++ - 3.8.

Now I would like to make this program available for 14.04, but since I use a lot of C ++ 14 features, I cannot just recompile it on that system. Instead, I wanted to ask if it is possible / how it is possible to package all the dependencies (specifically the C ++ standard library) so that I can just unzip the folder on the target system and run the application.

Ideally I am looking for some kind of automatic / scripted solution that I can add to my cmake build.

Bonus question:
For now, this is just a simple command line program for which I can easily recompile all third party dependencies (and in fact I do). However, in the long run, I would also like to ship a QT application. Ideally the solution will work for this scenario as well.

+3


source to share


1 answer


The worst part of your competition is the incompatible standard library. You should still link to it (see comments to your answer).

Several variants:

Fully static binding:

I think this is the easiest way for you, but it requires you to be able (or in some way) to create third party libraries as static. If you cannot for some reason this is not your option.

You just build your application as usual and then link it with all the libraries you need (see the documentation for your compiler). This way you get a fully executable without dependencies, it will work on any ABI-compliant system (you might need to check if the x86 executable is running on x86_64).

Partial static linking

You link statically whatever you can and dynamically the other. Therefore, you distribute all dynamic libraries ( *.so

) along with your application (in the folder path/to/app/lib

or path/to/app/

), so you do not depend on system libraries. Create a package deb

that will add all files to the folder /opt

or $HOME/appname

. You need to load all dynamic libraries "manually" or ask the compiler to do it at the link stage (see the documentation).



Docker container

I don't know much about this, but I do know for sure that it should install docker on the target system (not your option).

Useful links:

G ++ link options

static layout guide

Finding dynamic or shared libraries

There are similar docs for clang, google it.

+1


source







All Articles