简体   繁体   English

在 Linux 上分发纯二进制软件时,我不应该包含哪些共享库?

[英]Which shared libraries should I not include when distributing binary-only software on Linux?

The usual recommendation for handling the dependencies on Linux is by using the distro's package manager.处理 Linux 上的依赖项的通常建议是使用发行版的包管理器。

The good part of this approach is that you can reuse the basic set of libraries configured, tested, and updated for your system.这种方法的好处是您可以重用为您的系统配置、测试和更新的基本库集。

The bad part is that there are many distros with different package managers, and you probably have to support several of them.不好的部分是有许多具有不同包管理器的发行版,您可能必须支持其中的几个。 Users of not-so-popular distros have to work on their own to set up the dependencies.不那么流行的发行版的用户必须自己工作来设置依赖项。

The worst part is, when talking about games, some game distribution platforms ban the developer from using package files for installation.最糟糕的是,在谈论游戏时,一些游戏分发平台禁止开发者使用包文件进行安装。

Quotingitch.io ,引用itch.io

.deb and .rpm packages (Oh no tier) .deb 和 .rpm 包(哦,没有层)

These are ignored when looking for uploads - it'll appear as if your app wasn't available on Linux at all.这些在查找上传时会被忽略 - 它看起来好像您的应用在 Linux 上根本不可用。

Do not use these.不要使用这些。

To not use the package manager, one way is to build the app on a reasonably old system, like Debian oldstable or the Steam Runtime (based on Ubuntu 12.04), and distribute the final software by copying the shared libraries depended upon.要不使用包管理器,一种方法是在相当旧的系统上构建应用程序,例如 Debian oldstable 或 Steam Runtime(基于 Ubuntu 12.04),并通过复制所依赖的共享库来分发最终软件。

My question is which shared libraries should be copy-distributed in this stage.我的问题是在这个阶段应该复制分发哪些共享库。

Do I have to ship libc?我必须运送 libc 吗? If I don't, is it guaranteed that newer versions of libc has backwards compatibility with older versions of libc?如果我不这样做,是否可以保证较新版本的 libc 向后兼容较旧版本的 libc?

Can I just be safe and ship all the dependencies?我可以安全地运送所有依赖项吗? Will it work on most systems despite being a bit heavy?尽管有点重,它会在大多数系统上工作吗?

If that's not a solution, which shared libraries should I include and which not?如果这不是解决方案,我应该包含哪些共享库,哪些不包含?

Do I have to ship libc?我必须运送 libc 吗?

For reasons explained here , it is nearly guaranteed that your libc.so.6 will not be compatible with the system ld-linux.so (the path to system ld-linux.so is baked into your binary).由于此处解释的原因,几乎可以保证您的libc.so.6不会与系统ld-linux.so兼容(系统ld-linux.so的路径已包含在您的二进制文件中)。

You could however use a shell wrapper to avoid this problem.但是,您可以使用 shell 包装器来避免此问题。 Something along the lines of:类似于以下内容:

#!/bin/bash
TOP=/path/to/your/install
exec -a "mygame" "$TOP/lib64/ld-linux-x86-64.so.2" --library-path "$TOP/lib64" "$TOP/bin/mygame" 

If I don't, is it guaranteed that newer versions of libc has backwards compatibility with older versions of libc?如果我不这样做,是否可以保证较新版本的 libc 向后兼容较旧版本的 libc?

Yes, GLIBC backward compatibility guarantees exactly that: you could copy a binary from a system of 10 or 20 years ago, and it will run on a freshly installed latest distribution 1 .是的,GLIBC 向后兼容性完全保证:您可以从 10 或 20 年前的系统复制二进制文件,并且它将在新安装的最新发行版1上运行。

which shared libraries should I include and which not?我应该包含哪些共享库,哪些不包含?

Note that by distributing GPL software you assume certain obligations.请注意,通过分发GPL 软件,您承担了某些义务。 Talk to your lawyer if you plan to do that.如果您打算这样做,请咨询您的律师。


1 There have been a few bugs about 15 years ago where this backward compatibility was broken in some specific cases, but you are unlikely to run into them. 1大约 15 年前存在一些错误,这种向后兼容性在某些特定情况下被破坏,但您不太可能遇到它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM