linux - RHEL 链接器错误

标签 linux rhel

我在 x86_64 机器上使用 RHEL 5.8:

$ uname -r
2.6.18-308.1.1.el5
$ uname -m
x86_64
$

尝试将源代码交叉编译为 i386 兼容:

CFLAGS += -m32
LDFLAGS += -L/lib -lpthread -luuid

但链接阶段因错误而失败:

/usr/bin/ld: skipping incompatible /usr/lib64/libuuid.so when searching for -luuid
/usr/bin/ld: skipping incompatible /usr/lib64/libuuid.a when searching for -luuid
/usr/bin/ld: cannot find -luuid
collect2: ld returned 1 exit status

实际上,主机有/lib/libuuid.so.1.2:

$ readelf -h /lib/libuuid.so.1.2
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0xf90
  Start of program headers:          52 (bytes into file)
  Start of section headers:          13352 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         6
  Size of section headers:           40 (bytes)
  Number of section headers:         28
  Section header string table index: 27
$

是否有任何 ld 或其他选项来解决此链接问题?

最佳答案

链接器只搜索库名,没有版本号(“libuuid.so”)。惯例是将其符号链接(symbolic link)到 soname(在本例中为“libuuid.so.1”),后者又是到真正共享库(在本例中为“libuuid.so.1”)的符号链接(symbolic link)。所以.1.2​​").

因此,您需要在 /lib 中使用这些符号链接(symbolic link),以便链接器找到库。

(有关此主题的更多信息:http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html)

关于linux - RHEL 链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10118886/

相关文章:

linux - 从 RPM (rpm2cpio) 提取文件时出错

RHEL7.3下MYSQL安装问题

linux - 在电子邮件正文中发送 html 文件的输出

linux - 检查返回值的 shell 方法的错误代码

c - utf-8 字符串的最佳哈希是什么

linux - 如何从特定用户名查找在特定日期运行的命令

build - Mono 3.0.0 基于 CentOS 6 构建

regex - 使用正则表达式和 sed 过滤掉 IP

linux - 以非 root 用户身份运行服务

linux - 我如何在 Golang 程序中检测 linux 分布?