基于内核版本X.XX的C ++ Linux应用程序是否运行在早期版本上? [英] Will a C++ Linux app built on version X.XX of the kernel run on an earlier version?

查看:175
本文介绍了基于内核版本X.XX的C ++ Linux应用程序是否运行在早期版本上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题可能看起来很明显,我意识到我正在为大量的downvote,但我是非常新的Linux dev,只有一个工作了一段时间。



我已经在C ++上在ubuntu 12.04(内核3.2.0)上编写应用程序,然后通过scp将其复制到另一个ubuntu 8.04(内核2.6.30)设备。我一直注意到一些非常奇怪的行为,我根本不能解释。我天真地假设,我可以运行这个可执行文件以前的版本,但它开始在我的黎明,这实际上可能不是这样。在将来必须确保Linux版本我建立我的应用程序是相同的,它将在字段中运行?或者我必须实际上从源代码直接在设备上构建应用程序,它将运行?我非常新的Linux dev,但不是新的C + +所以我意识到,这个问题可能看起来很容易,但这是一个问题,我只是没有在书/教程等。


<大多数时候,不是内核阻止你,它是glibc。



glibc是向后的兼容,意味着编译和链接到较旧版本的程序将在运行时与较新版本完全相同。另一种方式是不兼容。



当然最好是基于你想运行它的发行版。如果你不能这样做,建立在最旧的glibc安装。



这也很难构建和链接到一个较旧的glibc比系统glibc,安装/构建glibc往往会弄乱你的系统超过它的价值。使用旧版本的Linux设置虚拟机,并改用它。


This question may seem blindingly obvious and I realise I am putting myself up for a large number of downvotes but I am very new to Linux dev and have only been working on it for a while.

I have been writing an application on ubuntu 12.04 (kernel 3.2.0) in C++ then copying this via scp to an ubuntu 8.04 (kernel 2.6.30) installation on another device. I have been noticing some very strange behaviour that I simply cannot explain. I have naively assumed that I can run this executable on a previous version, but it is beginning to dawn on me that this in fact may not be the case. In future must I ensure that the Linux version I build my application on is identical to that which it will be running on in the field?? Or must I actually build the application from source code directly on the device it will be running on??? I am very new to Linux dev but not new to C++ so I realise that this question may seem facile, but this is the kind of issue that I have simply not seen in books/tutorials etc.

解决方案

Most of the time, it's not the kernel that stops you, it's glibc.

glibc is backwards compatible, meaning programs compiled and linked to an older version will work exactly the same with a newer version at runtime. The other way around is not that compatible.

Best is of course to build on the distro you want to run it. If you can't do that, build on the one with the oldest glibc install.

It's also very hard to build and link to an older glibc than the system glibc, installing/building glibc tends to mess up your system more than it's worth. Set up a VM with an old Linux, and use that instead.

这篇关于基于内核版本X.XX的C ++ Linux应用程序是否运行在早期版本上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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