简体   繁体   English

Linux 针对不同 GLIBC 版本的“交叉编译”

[英]Linux “cross-compilation” for different GLIBC version

My work configuration is that I have Ubuntu-20-based development workstation (exactly Linux Mint 20.1) where I develop application for Ubuntu 18. When I compile simple C or C++ program, upload it to the target machine and run, I receive the message: My work configuration is that I have Ubuntu-20-based development workstation (exactly Linux Mint 20.1) where I develop application for Ubuntu 18. When I compile simple C or C++ program, upload it to the target machine and run, I receive the message :

./test: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by ./test)
./test: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by ./test)

Can I force the program to link to the older version?我可以强制程序链接到旧版本吗? I use gcc 9 if it does matter.如果确实重要,我会使用 gcc 9。

The canonical solution is create a chroot environment for the target version with debootstrap, as:规范的解决方案是使用 debootstrap 为目标版本创建一个 chroot 环境,如下所示:

debootstrap --variant=buildd --arch amd64 bionic ~/bionic_chroot

and activating that chroot with并激活那个 chroot

chroot ~/bionic_chroot

and do the compilation within chroot.并在 chroot 中进行编译。 See for example here for further details.有关更多详细信息,请参见此处的示例。

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

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