Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will a copied executable run on a new machine without the libraries

If I compile a C++ program on a linux box that has many libraries installed (Boost for example) and then copy that executable to a new linux box without those libraries, will the executable still run properly?

like image 449
Josh Brittain Avatar asked Oct 06 '22 03:10

Josh Brittain


1 Answers

This depends a lot on the specific libraries. There are three kinds of libraries out there:

  • Header-only libraries - these dependencies are resolved at compile time.
  • Static libraries - these dependencies are resolved at link time.
  • Shared (dynamic) libraries - these dependencies are resolved at run time.

Most Boost libraries are header-only: they require no separately-compiled library binaries or special treatment when linking. Other libraries are static, i.e. they are needed only at build time for linking. The only libraries that must be available on the target machine are dynamic (shared) libraries; if you have no dynamic library dependencies, copying an executable and setting the appropriate permissions will work fine.

like image 171
Sergey Kalinichenko Avatar answered Oct 10 '22 01:10

Sergey Kalinichenko