如何调查和修复丢失的库和/或跳过不兼容的库?

如何调查和修复丢失的库和/或跳过不兼容的库?

我有一个为 CentOS 6.5 构建的秘密库作为一个包。我无法为 CentOS 7.4 构建软件包,在这一行上 make install 失败:

$ gcc -static -O3 -Wno-long-long -funroll-loops -Wall -g -DLINUX testlib.c -o test-lib -L. -llsh -lstdc++

/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: cannot find -lc

我试图对此进行调查,例如:

$ ld -lstdc++ --verbose
...
attempt to open /usr/x86_64-redhat-linux/lib64/libstdc++.so failed
attempt to open /usr/x86_64-redhat-linux/lib64/libstdc++.a failed
attempt to open /usr/lib64/libstdc++.so failed
attempt to open /usr/lib64/libstdc++.a failed
attempt to open /usr/local/lib64/libstdc++.so failed
attempt to open /usr/local/lib64/libstdc++.a failed
attempt to open /lib64/libstdc++.so failed
attempt to open /lib64/libstdc++.a failed
attempt to open /usr/x86_64-redhat-linux/lib/libstdc++.so failed
attempt to open /usr/x86_64-redhat-linux/lib/libstdc++.a failed
attempt to open /usr/local/lib/libstdc++.so failed
attempt to open /usr/local/lib/libstdc++.a failed
attempt to open /lib/libstdc++.so failed
attempt to open /lib/libstdc++.a failed
attempt to open /usr/lib/libstdc++.so failed
attempt to open /usr/lib/libstdc++.a failed
ld: cannot find -lstdc++

我查看了一些路径,发现了这个: /usr/lib/libstdc++.so.6 我创建了符号链接(试图欺骗这个),但又出现了另一个错误:

$ sudo ln -s /usr/lib/libstdc++.so.6.0.19 /usr/lib/libstdc++.so

$ ld -lstdc++ --verbose
...
attempt to open /usr/x86_64-redhat-linux/lib64/libstdc++.so failed                                                                                                                                                 
attempt to open /usr/x86_64-redhat-linux/lib64/libstdc++.a failed                                                                                                                                                  
attempt to open /usr/lib64/libstdc++.so failed                                                                                                                                                                     
attempt to open /usr/lib64/libstdc++.a failed            
attempt to open /usr/local/lib64/libstdc++.so failed                                                     
attempt to open /usr/local/lib64/libstdc++.a failed                            
attempt to open /lib64/libstdc++.so failed                                    
attempt to open /lib64/libstdc++.a failed           
attempt to open /usr/x86_64-redhat-linux/lib/libstdc++.so failed
attempt to open /usr/x86_64-redhat-linux/lib/libstdc++.a failed                                          
attempt to open /usr/local/lib/libstdc++.so failed                                                       
attempt to open /usr/local/lib/libstdc++.a failed   
attempt to open /lib/libstdc++.so succeeded         
ld: skipping incompatible /lib/libstdc++.so when searching for -lstdc++                                                           
attempt to open /lib/libstdc++.a failed             
attempt to open /usr/lib/libstdc++.so succeeded                          
ld: skipping incompatible /usr/lib/libstdc++.so when searching for -lstdc++
attempt to open /usr/lib/libstdc++.a failed                                                              
ld: cannot find -lstdc++

CentOS 6.5:

$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)

CentOS 7.4:

$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)

请帮助解决这个问题。另外,期待获得一些如何调查此类问题的建议。

答案1

尝试安装:

  • libstdc++-静态
  • glibc 静态

从Redhat 7/CentOS 7开始,静态库被移至可选包中。在 CentOS 6 中,它是以下内容的一部分:

  • libstdc++-开发
  • glibc 开发

答案2

您可能需要devel库的版本,因此安装:

  • libstdc++-devel-4.8.5-16.el7
  • glibc-devel-2.17-196.el7

相关内容