Compiling Rust Programs for CentOS on Ubuntu

Now CentOS 8 is not out yet, the latest is CentOS 7.6, and the glibc version on it is 2.17, which is already the version in 2012.

The desktop Linux systems commonly used by developers now, such as Ubuntu / Debian / Mint / Arch / Manjaro, etc., are relatively new glibc versions, such as Ubuntu 18.04 has reached version 2.27. In glibc 2.18, a __cxa_thread_atexit_impl flag was introduced, all dynamic link programs compiled based on glibc environment 2.18 and above, if they are run in glibc environment before 2.18, an error will be reported:

./foo: /lib/libc.so.6: version 'GLIBC_2.18' not found (required by ./foo)

This is also the reason why a Rust helloworld program compiled on Ubuntu cannot run on CentOS.

I also thought about upgrading the glibc version on CentOS. Later, I found that it was too dangerous. I tried to compile and upgrade manually on the virtual machine. As a result, CentOS was hung up, and I couldn't even get up!

Then I had to run a CentOS in the virtual machine to compile the Rust program, so the compiled program ran happily on the CentOS server, but running CentOS in the virtual machine was really unbearable. I made a partition on the machine to install a set of CentOS again, but I was not willing to give up such a good Mint system and use the crappy CentOS instead.

Later, I got advice from experts and tried to use Docker to run a CentOS system on Mint to compile Rust programs, and found that this works very well! At first I thought that the 3.X kernel used by CentOS by default would have problems running on the 4.15 kernel, but it was found that there was no problem.

In the future, try not to use CentOS, it will be much better to replace it with Ubuntu Server!

{{o.name}}
{{m.name}}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324031316&siteId=291194637