1

C++动态库向前兼容的能力,真是一言难尽。

 1 year ago
source link: https://www.v2ex.com/t/909407
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  C++

C++动态库向前兼容的能力,真是一言难尽。

  tool2d · 9 小时 29 分钟前 · 2460 次点击
公司有个运行在外网的生产环境,是 linux 早期版本,本着只要代码能运行,就没人去动的原则,内核一直比较老。

然后我想加一点小功能,想着现在 clang 那么强大了,跨平台编译应该轻轻松松,然而测试结果让我大跌眼镜。

目前几乎所有的 clang 交叉编译环境,都是基于新版本的 GLIBC ,相当于 VC 的 Runtime Lib ,而这货竟然严重依赖于系统内核版本?测试了好几个打包编译器,都是顺利生成 ELF ,可运行报错,提示让先升级内核。

无奈,一点点换老款编译器,从 2022 年的 clang ,到 2020 年的 clang ,到 2012 年的 gcc, 再到 2007 年的 gcc ,最后一个终于运行成功!

硬着头皮,用最原始的编译器,写最炫酷的 2023 新代码。

第 1 条附言  ·  4 小时 6 分钟前

ZbaUZHO.jpg


补一张错误图吧,是静态链接,也就一个 hello world ,运行就报"kernel too old"。

很多人没遇见过 GLIBC 内核不兼容问题。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK