How to pack C ++ with DLLs and libraries

I am wondering how to “pack” a C ++ project for release. It uses different libraries, and I do not want the user to go through the same settings as me, with the right files in the right place, etc. It was hard for me to research this, because I'm not sure if this is a technical term for this problem. If I use command line compilation on Linux, is there an easy way to do this?

+6
source share
3 answers

Your approach to this will be different on Windows and Linux, because each OS handles it differently. I am more familiar with Linux, so I will limit my answer only to the Linux side.

When you link your executable file to a library using the -l flag, by default the linker searches the regular directories of system libraries, so there are four approaches.

  • Require the user to properly install the libraries themselves. However, it seems you do not want to do this.

  • Ask the user to add the library location to the LD_LIBRARY_PATH variable.

  • Your third parameter causes the linker to search in a specific path for libraries using the -rpath flag. For example, so that the application looks in its working directory for a shared library that you can compile with: g++ -rpath ./ -l SomeLib -o MyApp myapp.cpp

  • Another option is static links to your code with their library in such a way that you only need to distribute one executable file. If a static library exists, you can use g++ -static -l SomeLib -o MyApp myapp.cpp to tell gcc a static mapping.

+4
source

In windows, I recommend wix http://wix.sourceforge.net/ for creating the .msi installer. I would like to specify the search path for .dlls. I recommend putting all .dlls in the same folder as your .exe, as it has highest priority

However, vc crt (c / C ++ runtime library) must be installed using the redistribution package from microsoft -> updates automatically http://www.microsoft.com/de-de/download/details.aspx?id= 5555

Wix may include a redistribution package in the same .msi, so you only need to deploy one installer file.

+2
source

Do you mean the installer?
On Windows, the program that you run to install the new application, which displays everything in the correct directory, creates the Start menu and allows you to remove it?

Visual Studio has an installer installer (it may not be in the free express version) that makes the MSI installer files. It is fairly easy to use for simple tasks, but it becomes difficult to do something else.

As an alternative to creating traditional setup.exe-type installations, I use the excellent free Innosetup

On Linux, you usually create a package using any format used by your distribution (.deb / .rpm). There are many instructions on the specifics of each, and the tools for this will probably already be installed on your Linux system.

+1
source

Source: https://habr.com/ru/post/917645/


All Articles