The basics of compiling dependency-free binary files using the gnu toolchain

I'm trying to create an audio file that I create by slowing down with SoX , and although I can easily compile the source files to the Linux machine that I use regularly, I need to transfer the binary to another Linux machine with limited permissions and memory. I tried to copy the binary from the usr / local / bin folder on my machine to another, and it could not find function references.

Is there a standard way to compile binaries without dependencies, and if not, how to configure the SoX binary so that it sees the correct dependencies when I only have write permissions in the temporary folder?

+4
source share
2 answers

You can compile by adding the -static flag to the compilation options in the Makefile . But keep in mind any differences in glibc versions between two (or more) Linux workstations. You want to make sure that you are compiling a workstation (or target) for it with an older (or oldest) kernel, or your binary may not work due to dependencies on a newer kernel, which the old Linux installation cannot satisfy . So: basically, compile your old machine for best results.

+2
source

The most important thing you need to create executable files without dependencies is the static version of all the libraries that this executable will use. Libraries are usually also shares, that is, if they need to call other library functions, they use a shared link. In order not to get dependencies of the 2nd level, you need to statically install all the necessary libraries.

+2
source

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


All Articles