简体   繁体   中英

Symbol lookup error undefined symbol, but all symbols seem to be present

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 shows that the symbol auth_class_names is defined:

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

All clues and ideas welcome

EDIT: Outputs of ldd added:

/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 shows that the symbol auth_class_names is defined

No: it shows that auth_class_names is un defined in libcharon.so .

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

Wrong again: libcharon.so does reference the symbol.

ldd /usr/lib/libstrongswan.so

That's not what you want. You want ldd /usr/lib/libcharon.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.

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

  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).

  2. Link charon binary against libstrongswan.so .

  3. Dynamically load libstrongswan.so before you load libcharon.so .
  4. LD_PRELOAD=libstrongswan.so

Actually "U" means, that symbol is undefined. What does ldd show on your libcharon.so.0 ? libstrongswan.so.0 is where you should find auth_class_names .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM