符号查找错误未定义符号,但似乎所有符号都存在 [英] Symbol lookup error undefined symbol, but all symbols seem to be present

查看:264
本文介绍了符号查找错误未定义符号,但似乎所有符号都存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可执行文件似乎无法解析链接库中的符号. LD_DEBUG = libs的相关输出显示正确的库已加载: 6557: /usr/lib/libcharon.so.0: error: symbol lookup error: undefined symbol: auth_class_names (fatal) /usr/libexec/ipsec/charon: symbol lookup error: /usr/lib/libcharon.so.0: undefined symbol: auth_class_names

An executable seemingly can't resolve a symbol in a linked library. The relevant output of LD_DEBUG=libs shows that the correct library is loaded: 6557: /usr/lib/libcharon.so.0: error: symbol lookup error: undefined symbol: auth_class_names (fatal) /usr/libexec/ipsec/charon: symbol lookup error: /usr/lib/libcharon.so.0: undefined symbol: auth_class_names

nm -D显示定义了符号auth_class_names:

nm -D shows that the symbol auth_class_names is defined:

nm -D /usr/lib/libcharon.so.0|grep auth_class_names U auth_class_names

nm -D /usr/lib/libcharon.so.0|grep auth_class_names U auth_class_names

欢迎所有线索和想法

添加了ldd的输出:

/usr/lib# ldd /usr/lib/libstrongswan.so
    libpthread.so.0 => /lib/arm-linux-gnueabi/libpthread.so.0 (0xb6ecd000)
    libdl.so.2 => /lib/arm-linux-gnueabi/libdl.so.2 (0xb6ec2000)
    librt.so.1 => /lib/arm-linux-gnueabi/librt.so.1 (0xb6eb3000)
    libc.so.6 => /lib/arm-linux-gnueabi/libc.so.6 (0xb6d78000)
    /lib/ld-linux.so.3 (0xb6f25000)
/usr/lib# ldd /usr/lib/libcharon.so
    libm.so.6 => /lib/arm-linux-gnueabi/libm.so.6 (0xb6ea6000)
    libpthread.so.0 => /lib/arm-linux-gnueabi/libpthread.so.0 (0xb6e86000)
    libdl.so.2 => /lib/arm-linux-gnueabi/libdl.so.2 (0xb6e7b000)
    libcap.so.2 => /lib/arm-linux-gnueabi/libcap.so.2 (0xb6e70000)
    libc.so.6 => /lib/arm-linux-gnueabi/libc.so.6 (0xb6d35000)
    /lib/ld-linux.so.3 (0xb6fa6000)
    libattr.so.1 => /lib/arm-linux-gnueabi/libattr.so.1 (0xb6d27000)

# nm -D /usr/lib/libstrongswan.so|grep auth_class
00036a50 D auth_class_names

推荐答案

nm -D显示定义了符号auth_class_names

nm -D shows that the symbol auth_class_names is defined

否:表明auth_class_names是在libcharon.so中定义的 un .

No: it shows that auth_class_names is undefined in libcharon.so.

libstrongswan提供auth_class符号,但libcharon不引用它.

libstrongswan provides the auth_class symbol, but libcharon doesn't reference it.

再次错误:libcharon.so 确实引用了该符号.

Wrong again: libcharon.so does reference the symbol.

ldd /usr/lib/libstrongswan.so

这不是您想要的东西.您要ldd /usr/lib/libcharon.so.

That's not what you want. You want ldd /usr/lib/libcharon.so.

您的问题很可能是邻居libcharon.so或主可执行文件都未链接到libstrongswan.so,因此,当您动态加载libcharon.so时,找不到libstrongswan.so了;因此,加载失败并带有未定义的符号.

Your problem is most likely that neigher libcharon.so, nor the main executable were linked against libstrongswan.so, so when you dynamically load libcharon.so, libstrongswan.so is nowhere to be found; hence the loading fails with undefined symbol.

有几种可能的解决方案,从更正确到更hacky:

There are several possible solutions, ordered from more correct to more hacky:

  1. libcharon.solibstrongswan.so链接.加载libcharon.so将加载其所有依赖项(现在将包含libstrongswan.so,并且将找到符号).

  1. Link libcharon.so against libstrongswan.so. Loading libcharon.so will load all of its dependencies (which will now include libstrongswan.so, and the symbol will be found).

charon二进制文件链接到libstrongswan.so.

这篇关于符号查找错误未定义符号,但似乎所有符号都存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆