为多个平台构建linux二进制文件 [英] Building linux binaries for multiple platforms

查看:134
本文介绍了为多个平台构建linux二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

帮我解决一个分数。



我有一个用C ++编写的软件,意味着尽可能多地运行linux发行版,我需要找出一个有效的策略。我试图运送二进制文件在这种情况下不是源代码(可能是好知道)。 它已经是一个商业产品,我有知识产权问题,阻止我开源产品,但也意味着我必须处理无数的GPL问题。



当前的推理是选择一个最小公分母,并构建一切。


  1. 旧版GCC中的C ++支持缺少一些更现代的C ++特性。 li>
  2. 最小公约数必须是Red Hat Enterprise Linux 4(RHEL4)

需要整个C ++ 11功能集,但我想带来的C ++支持Visual C ++ 2010.我正在思考使用Clang / libc ++,而不是GCC / libstdc ++尽可能。 p>

RHEL4似乎没有广泛的跨平台支持构建C ++应用程序,更多的,我几乎没有洞察ABI在不同版本的linux的稳定性,但我担心RHEL4比麻烦更值。试图基于几个版本构建所有的发行版是不可行的策略。



我的假设是编译软件为不同版本的linux最好通过编译该软件用于目标平台上的工具在目标平台上。我目前还在假设你将遇到巨大的可移植性问题跨Linux平台,如果你不接受这一点。不要谈论你可以或不能链接的许多库,因为平台/发行版之间的C ++ ABI不稳定。



但我可能是错的,我想听到来自定期处理这个问题的人。什么将工作,为什么?

解决方案

您可以尝试关注几个主要平台,而不是个别分发。我的意思是建立在我所谓的基础发行版(Debian和RedHat),并希望在其他人上最好。



很可能,Debian二进制文件(静态链接)将运行在Ubuntu和Mint和其他Debian派生分布。 RedHat二进制文件可能在Centos,Scientific Linux和SuSE Linux上运行。如果你关心不太受欢迎的发行版(假设你有很多客户运行一些不常见的Linux),并且你的Debian或RedHat可执行文件不能工作在他们或可以使其工作在某种方式,然后设置一个VM的发行版,并构建一个可执行文件



我过去采用这种方法,效果很好。


Help me settle a score.

I have a piece of software written in C++ that's meant to run on as many linux distributions as possible and I need to figure out a strategy that's effective. I'm trying to ship binaries in this case not source code (might be good to know). It's already a commercial product and I have intellectual property issues that prevent me from open sourcing the product but also means I have to deal with a myriad of GPL issues.

The current line of reasoning has been to pick a least common denominator and build everything off that. That has two major implications that I find counter productive.

  1. The C++ support in old versions of GCC lacks some more modern C++ features.
  2. The least common denominator entails Red Hat Enterprise Linux 4 (RHEL4)

I definitely don't need the the entire C++11 feature set but I'd like to bring the C++ support up to that of Visual C++ 2010. I'm perusing the idea to use Clang/libc++ as opposed to GCC/libstdc++ where possible.

RHEL4 doesn't seem to have extensive cross platform support for building C++ applications, more over, I have little insight in the stability of ABI across different versions of linux but I'm concerned that RHEL4 is more trouble than worth. Trying to build for all distributions based on a few is not a viable strategy.

I'm under the assumption that compiling software for different distributions of linux is best accomplished by compiling the software for the target platform with tools on the target platform. I'm also currently operating under the assumption that you'll run into vast portability issues cross linux platforms if you do not embrace this. Not to talk about the many libraries that you can or cannot link with because of C++ ABI instability across platforms/distributions.

But I could be wrong, I'd like to hear from the people that deal with this on a regular basis. What will work and why? or more importantly, what will not work?

解决方案

You may try to focus on a few major platforms rather than individual distributions. What I mean by that is to build on what I call the "foundational distros" (Debian and RedHat) and hope for the best on the others.

Most likely, Debian binaries (that are statically linked) will run just fine on Ubuntu and Mint and other Debian derived distributions. RedHat binaries will probably run on Centos, Scientific Linux and SuSE Linux. If you care about less popular distros (Say you have a lot of customers running some uncommon Linux), and neither your Debian or RedHat executable works on them or can be made to work somehow, then setup a VM of that distro and build one executable specifically for that flavor.

I've taken this approach in the past and it has worked well.

这篇关于为多个平台构建linux二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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