使用 gnu 工具链编译无依赖关系的二进制文件的基础知识
我正在尝试使用 SoX 减慢我创建的音频文件的速度,尽管我可以轻松编译源代码当我经常使用的 Linux 机器上的文件时,我需要将二进制文件传输到另一台权限和内存有限的 Linux 机器上。我尝试将二进制文件从我的计算机上的 usr/local/bin 文件夹复制到另一台计算机,但它找不到函数引用。
是否有一种标准方法来编译没有依赖项的二进制文件,如果没有,如何设置 SoX 二进制文件,以便当我在临时文件夹中只有写入权限时它可以看到正确的依赖项?
I'm trying to make an audio file I create slow down using SoX, and although I can easily compile the source files on the linux machine 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 the other one and it could not find function references.
Is there a standard way to compile binaries with no dependencies, and if not, how do I set up the SoX binary so that it sees the correct dependencies when I only have write privileges in a temp folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以进行编译,将
-static
标志添加到Makefile
中的编译选项中。但请注意两个(或多个)Linux 工作站之间glibc
版本的任何差异。您需要确保在具有较旧(或最旧)内核的工作站上进行编译(或目标为),否则您的二进制文件可能由于依赖于较新的内核而无法工作,而较旧的 Linux 安装无法满足这一要求。所以:基本上,在最旧的机器上编译以获得更好的结果。You can compile, adding the
-static
flag to the compilation options in theMakefile
. But be aware of any differences inglibc
versions between your two (or more) Linux workstations. You want to make sure that you compile on (or target for) the workstation with the older (or oldest) kernel, or your binary may not work due to dependencies on a newer kernel, which cannot be met by an older installation of Linux. So: basically, compile on your oldest machine for better results.生成没有依赖项的可执行文件所需的最重要的事情是该可执行文件将使用的所有库的静态版本。通常,库也是共享的,这意味着如果它们需要调用另一个库的函数,它们会使用共享链接。为了不获得二级依赖项,您需要静态编译所有必需的库。
The most important thing you need to generate executables without dependencies is the static version of all libraries this executable will use. Usually, libraries are shares as well, meaning if they need to call another library's functions, they use shared linking. To not get 2nd-grade dependencies you need to compile all required libraries statically.