【SystemTap】c独立安装elfutils导致错误 cannot load ld backend library 'libld_elf_x86_64.so' 和 error: C compiler cannot create executables

来源:互联网 发布:手机淘宝版本大全 编辑:程序博客网 时间:2024/06/06 09:01

场景:

        运行程序时出现了一系列的错误,例如:

(1)编译内核执行命令 make menuconfig 命令时出现如下错误:

/usr/local/bin/ld: cannot load ld backend library 'libld_elf_x86_64.so':
libld_elf_x86_64.so: cannot open shared object file: No such file or directory

/usr/local/bin/ld: cannot load ld backend library 'libld_elf_x86_64.so': libld_elf_x86_64.so: 无法打开共享对象文件: 没有那个文件或目录

(2)执行 systemtap下的 ./configure 出现如下错误

checking for C compiler default output file name...
configure: error: in `/local/zkl/systemtap-1.1':
configure: error: C compiler cannot create executables
See `config.log' for more details.

{

      我查看 config.log 文件,搜索 " C compiler default output file name ",发现以下几行

         configure:2913: checking for C compiler default output file name
         configure:2935: gcc    conftest.c  >&5
         /usr/local/bin/ld: cannot load ld backend library 'libld_elf_x86_64.so': libld_elf_x86_64.so: cannot open shared  object file: No such file or directory

}

两个错误实际上都是  'libld_elf_x86_64.so' 造成的。

 

原因分析:

独立安装 elfutils-0.137 后导致的一系列致命错误:

错误描述

回想我的操作,可能是因为我安装 elfutils-0.137  的缘故,因为SystemTap需要elfutils支持,所以我下载了 elfutils-0.137,解压后执行了:./configure,make,make install 进行安装,然后就出现了这一系列莫名奇妙的错误。libld_elf_x86_64.so 应该是elfutils的库,最开始也不知道是elfutils导致的问题。

 

网上找了好久,终于在下面的一个网站中找到了眉目: http://permalink.gmane.org/gmane.linux.systemtap/16482

它描述原因是:

The error was because I had "make install" the downloaded elfutils, which subsequently installed "ld" and "ar" into /usr/local/bin, and these latter binaries are not working properly.   But as systemtap just need the source of elfutils, it is not need to "make install" for the elfutils.

download elfutils sources, untar into some directory, then configure systemtap with --with-elfutils=THE_ELFUTILS_SOURCE_DIRECTORY/.

 

原来是因为make install 安装elfutils生成的库不能正常工作,systemtap的安装仅仅是需要elfutils源码(执行 ./configure --with-elfutils=THE_ELFUTILS_SOURCE_DIRECTORY ),而不是首先 make install 安装 elfutils

 

因此,归结为,独立安装 elfutils-0.137 导致了错误: /usr/local/bin/ld: cannot load ld backend library 'libld_elf_x86_64.so': libld_elf_x86_64.so: cannot open shared object file: No     such file or directory。应该是执行ld命令检查库依赖时出现了问题,

 

解决办法:

进入 elfutils-0.137 目录,按以下顺序执行命令卸载 elfutils,
make uninstall;
make distclean;

注意执行这些命令都需要Makefile文件,而elfutils是通过 ./configure 生成Makefile文件,因此若发现没有makefile文件,则需要在一台没有问题的机器上执行 ./configure 命令生成 Makefile 文件,然后再拷贝过来,再对 elfutils 进行卸载。

 

原创粉丝点击