将C ++编译为可移植的Linux二进制文件 [英] Compiling C++ into portable linux binaries

查看:253
本文介绍了将C ++编译为可移植的Linux二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,这个问题是关于便携式的,例如没有依赖项(例如,我可以将二进制文件放入USB密钥中,并随身携带它,电子邮件,他们给朋友等".

Ok, this question is about portable as in no dependencies (i.e. "I can put the binaries in a USB key and bring it with me everywhere, e-mail them to friends etc").

我听说过静态链接,但是我对它的确切后果感到困惑;哪些可以静态链接,哪些不能静态链接(即Qt,OpenGL,libstdc ++呢?),然后二进制将在多大程度上可移植"呢?

I have heard of static linking but I'm confused to what are exactly the consequences of it; what can and what can't be static linked (i.e. what about Qt, OpenGL, libstdc++?) and to which degree the binary will be "portable" afterwards.

我也听说过 LSB (Linux标准库),但是我不知道它到底是什么,或者在这种意义上它是否可以帮忙.

I've also heard of LSB (Linux Standard Base) but I don't know exactly what it is or if it can help in this sense.

推荐答案

静态链接适用于大多数库,但不适用于使用动态加载模块的库.只是尝试看看是否可行.您可能仍然对内核兼容性有疑问.您的程序可能正在使用旧内核中不可用的系统调用.

Static linking works for most libraries, but not those that use dynamically loaded modules. Just try and see if it works. You may still have issues with kernel compatibility; your program may be using system calls not available in older kernels.

某些Linux发行版支持Linux Standard Base,但在 Debian 上(我也认为Ubuntu ),则必须从软件包中进行安装.尽管它具有一些二进制兼容性的东西,但它也处理大多数管理事务,例如启动脚本.有关某些信息,请参见此页面.

The Linux Standard Base is supported by some Linux distros, but on Debian (and I think also Ubuntu) it has to be installed from a package. It also handles mostly administrative things like startup scripts, though it has some binary compatibility stuff. See this page for some info.

有关插入USB密钥并在任何地方运行"的要求,请查看 CDE .

For the "put on USB key and run anywhere" requirement, check out CDE.

这篇关于将C ++编译为可移植的Linux二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆