View glibc version and resolve differences

Check the native glibc version:

ldd --version

 

----------------------------

The library compiled on machine A, use the time report for B: undefined reference to `expf@GLIBC_2.27'

After viewing with the above command,

Version A: ldd (Ubuntu GLIBC 2.27-3ubuntu1.2) 2.27

Version B: ldd (Ubuntu GLIBC 2.23-0ubuntu11) 2.23

 

Find further information:

The highest glibc version available in Ubuntu 16.04 (as of July 2019) is 2.23,

but the linker is stating your version is 2.27, which suspiciously corresponds to the one shipped in Ubuntu 18.04

 

Try to lower the GCC version,

B's GCC is 5.4.0,

A is Ubuntu18.04, gcc is 7.3.0, and the minimum supported gcc version is 5.5.0

Try to install

查看支持的最低版本
apt-cache policy gcc-5


一、利用软链接的方式进行gcc的降级

1、apt-get安装gcc、g++,默认下载最新版本的,此时ubuntu里的gcc和g++版本均为7.3.0。

sudo apt-get install gcc

sudo apt-get install g++

gcc -v   //查看的版本为7.3.0

g++ -v   //查看的版本为7.3.0

2、apt-get 安装gcc、g++ 5版本,利用apt-get 安装gcc5.4.0版本时显示没有该版本资源,因此改为gcc.5版本。

sudo apt-get install -y gcc-5

sudo apt-get install -y g++-5

gcc-5版本已经下载好,通过下载时输出的信息来看下载的版本实际为gcc 5.5.0-12ubuntu1

3、删除原有gcc链接,重新建立软链接。

cd /usr/bin 

sudo rm -r gcc //移除之前的软链接

sudo ln -sf gcc-5 gcc // 建立gcc-5的软链接 此处尝试使用gcc-5.5.0,但是报错

sudo rm -r g++  //同上

sudo ln -sf g++-5 g++  //同上

4、此时,gcc的版本已经成功的从7.3.0下降到5.5.0版本,利用gcc -v查看版本号发现已经更新为gcc 5.5.0。

上处软链接时使用的时gcc-5,显示的版本为gcc 5.5.0,考虑原因应该时在使用apt-get下载时使用的是gcc-5的原因。

Can use!

Guess you like

Origin blog.csdn.net/yxpandjay/article/details/111226110