Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy an executable with all needed libraries?

I have two fairly identical (Linux-) systems but one with just a minimum set of packages installed. On one system I have a running (binary/ELF) executable which I want to copy over to the other system (with the minimum setup).

Now I need a way to copy all needed shared libraries as well. Currently I start the application on the source system and then go through the output of

lsof | grep <PID> 

or

ldd <FILE>

to get a list of all libraries currently loaded by the application and copy them over manually.

Now my question is: before I start to automate this approach and run into lots of little problems and end up with yet another reinvented wheel - Is there a tool which already automates this for me? The tool I'm dreaming of right now would work like this:

$ pack-bin-for-copy <MY_EXE>

which creates a .tgz with all needed shared libraries needed to run this executable.

or

$ cp-bin <MY_EXE> user@target:/target/path/

which would just copy the binary once..

Note: I do NOT need a way to professionally deploy an application (via RPM/apt/etc.). I'm looking for a 'just for now' solution.

like image 325
frans Avatar asked Mar 28 '17 07:03

frans


People also ask

Which command shows all shared libraries required by a binary executable or another shared library?

Using the ldd Command The syntax to use this command is pretty straight forward: ldd [option]... file... The ldd command is pretty handy to list the shared libraries of a program.

What is the difference between a library and an executable?

Executable file will have to be recompiled if any changes were applied to external files. In shared libraries, no need to recompile the executable. Takes longer to execute, because loading into the memory happens every time while executing. It is faster because shared library code is already in the memory.

Is a shared library an executable?

Shared library are the one which do some task that is commonly accessed or used by many executables. These library are loaded into the memory only once and accessed by many programs(executables) at runtime.

What is a library executable?

The executable library is a structured collection of development objects that users can call directly. An executable fulfills a process step function. For instance, a transaction or an SAP FIORI application can be called by a user. Accordingly, you can consider them executables.


1 Answers

One tool that does something similar to what you suggest is linuxdeploy. While the tool is intended to ease the creation of an AppImage (see here for more information), it will pack your executable with any dependencies into a directory. Then you can just create a 'tgz' file of that directory instead of an AppImage.

like image 105
Guillermo Frontera Avatar answered Oct 04 '22 14:10

Guillermo Frontera