LinearTapeFileSystem / ltfs

Reference implementation of the LTFS format Spec for stand alone tape drive
BSD 3-Clause "New" or "Revised" License
256 stars 77 forks source link

ltfs: symbol lookup error: ltfs: undefined symbol: ltfs_load_tape #325

Closed TyrasNistru closed 2 years ago

TyrasNistru commented 2 years ago

After a clean build, following the instructions, when I try to run ltfs (even with no arguments), it returns the following error:

ltfs: symbol lookup error: ltfs: undefined symbol: ltfs_load_tape

To Reproduce build with: $ ./autogen.sh $ ./configure $ make $ sudo make install

Try to run $ ltfs

Expected behavior The basic help text for ltfs

The Build always complete successfully, but the install show some warnings: libtool: warning: relinking 'libtape-file.la' libtool: warning: relinking 'libtape-itdtimg.la' libtool: warning: relinking 'libtape-sg.la' libtool: warning: relinking 'libkmi-simple.la' libtool: warning: relinking 'libkmi-flatfile.la' libtool: warning: relinking 'libiosched-unified.la' libtool: warning: relinking 'libiosched-fcfs.la'

Am I doing something wrong?

piste2750 commented 2 years ago

It looks there is something wrong about dynamic binding of shared library. I will check the behavior on the environment.

ltfs: symbol lookup error: ltfs: undefined symbol: ltfs_load_tape

Could you provide which branch or tag you built ?

Finally, I don't think the warnings libtool: warning: relinking are related into the problem of undefined symbol.

piste2750 commented 2 years ago

Please try ldconfig and then run ltfs again. The error disappeared on my env like below. You might need to recreate shared library cache by ldconfig.

piste@bionic:~/ltfs$ sudo make install
Making install in messages
make[1]: Entering directory '/home/piste/ltfs/messages'
make[2]: Entering directory '/home/piste/ltfs/messages'
make[2]: Nothing to be done for 'install-exec-am'.
...
 /usr/bin/install -c -m 644  config.h '/usr/local/include/ltfs/.'
make[2]: Leaving directory '/home/piste/ltfs'
make[1]: Leaving directory '/home/piste/ltfs'
piste@bionic:~/ltfs$ sudo /usr/local/bin/ltfs
/usr/local/bin/ltfs: error while loading shared libraries: libltfs.so.0: cannot open shared object file: No such file or directory
piste@bionic:~/ltfs$ sudo ldconfig
piste@bionic:~/ltfs$ sudo /usr/local/bin/ltfs
5c23 LTFS14000I LTFS starting, LTFS version 2.5.0.0 (Prelim), log level 2.
5c23 LTFS14058I LTFS Format Specification version 2.4.0.
5c23 LTFS14104I Launched by "/usr/local/bin/ltfs".
5c23 LTFS14105I This binary is built for Linux (x86_64).
5c23 LTFS14106I GCC version is 7.5.0.
5c23 LTFS17087I Kernel version: Linux version 4.15.0-163-generic (buildd@lcy01-amd64-021) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #171-Ubuntu SMP Fri Nov 5 11:55:11 UTC 2021 i386.
5c23 LTFS17089I Distribution: NAME="Ubuntu".
5c23 LTFS17089I Distribution: DISTRIB_ID=Ubuntu.
5c23 LTFS14063I Sync type is "time", Sync time is 300 sec.
5c23 LTFS17085I Plugin: Loading "sg" tape backend.
5c23 LTFS17085I Plugin: Loading "unified" iosched backend.
5c23 LTFS14095I Set the tape device write-anywhere mode to avoid cartridge ejection.
5c23 LTFS30209I Opening a device through sg-ibmtape driver (0).
5c23 LTFS30288I Opening a tape device for drive serial 0.
5c23 LTFS12012E Cannot open device: failed backend open call.
5c23 LTFS10004E Cannot open device '0'.
TyrasNistru commented 2 years ago

Hello! Thanks for helping!

I built from the v2.4-stable branch, unmodified.

Tried running ldconfig as you suggested, but nothing changed. I didn't get the error you did in your log (error while loading shared libraries: libltfs.so.0: cannot open shared object file: No such file or directory), only the symbol lookup error.

piste2750 commented 2 years ago

I didn't get the error you did in your log (error while loading shared libraries: libltfs.so.0: cannot open shared object file: No such file or directory), only the symbol lookup error.

Oops, sorry for that. I might missed message in your first description.

I tried the code on the v2.4-stable branch. But I can't see such error at all. You need to check the function is actually existed or not.

  1. Run ldd /usr/local/bin/ltfs
    • This command lists the shared libraries that ltfs links dynamically
    • Search the line starts with libltfs.so.0 and fetch the absolute path of the library (/usr/local/lib/libltfs.so.0 in my case)
  2. Run nm /usr/local/lib/libltfs.so.0 and search ltfs_load_tape is existed (by the grep command)

Could you upload the output of step1 (ldd /usr/local/bin/ltfs) and step2 (nm /usr/local/lib/libltfs.so.0)?

TyrasNistru commented 2 years ago

Hello! Here's the output of the the commands you asked:

ldd:

linux-vdso.so.1 (0x00007fff215fe000)
libfuse.so.2 => /lib/x86_64-linux-gnu/libfuse.so.2 (0x00007f5846f34000)
libnetsnmpagent.so.30 => /usr/lib/x86_64-linux-gnu/libnetsnmpagent.so.30 (0x00007f5846ccb000)
libltfs.so.0 => /usr/local/lib64/libltfs.so.0 (0x00007f5846a15000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f584680d000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f58465ee000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f58461fd000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5845ff9000)
libnetsnmp.so.30 => /usr/lib/x86_64-linux-gnu/libnetsnmp.so.30 (0x00007f5845d1e000)
libwrap.so.0 => /lib/x86_64-linux-gnu/libwrap.so.0 (0x00007f5845b14000)
libperl.so.5.26 => /usr/lib/x86_64-linux-gnu/libperl.so.5.26 (0x00007f5845717000)
libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f5845510000)
libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f584514f000)
libicui18n.so.50 => /usr/local/lib/libicui18n.so.50 (0x00007f5844d55000)
libicuuc.so.50 => /usr/local/lib/libicuuc.so.50 (0x00007f58449df000)
libicudata.so.50 => /usr/local/lib/libicudata.so.50 (0x00007f584340d000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f584306f000)
/lib64/ld-linux-x86-64.so.2 (0x00007f5847388000)
libcrypto.so.1.1 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007f5842ba4000)
libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007f584298a000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f5842752000)
libicuuc.so.60 => /usr/lib/x86_64-linux-gnu/libicuuc.so.60 (0x00007f584239a000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f584217d000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f5841f57000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f5841bce000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f58419b6000)
libicudata.so.60 => /usr/lib/x86_64-linux-gnu/libicudata.so.60 (0x00007f583fe0d000)

nm /usr/local/lib64/libltfs.so: nm: /usr/local/lib64/libltfs.so: no symbols

looks like it is pointing to the wrong library. There is a libltfs.so (and the .0 notations of it) in /usr/local/lib that have the symbols:

nm /usr/local/lib/libltfs.so (grep'ed) 000000000001539b T ltfs_load_tape

TyrasNistru commented 2 years ago

I can just make the lib64 ones point to the lib ones through a symlink, but I I think that's just a workaround.

piste2750 commented 2 years ago

It looks something strange on your environment. Because libraries are installed into /usr/local/lib/ when the configure script is launched without any options on Ubuntu.

piste@bionic:~/ltfs$ ldd /usr/local/bin/ltfs
    ...
    libltfs.so.0 => /usr/local/lib/libltfs.so.0 (0x00007f46b0085000)
    ...

Do you replace something from the default OS modules?

I can see your machine has custom libicu like below.

libicui18n.so.50 => /usr/local/lib/libicui18n.so.50 (0x00007f5844d55000)
libicuuc.so.50 => /usr/local/lib/libicuuc.so.50 (0x00007f58449df000)
libicudata.so.50 => /usr/local/lib/libicudata.so.50 (0x00007f584340d000)
TyrasNistru commented 2 years ago

Do you replace something from the default OS modules?

No, not that I'm aware.

I can see your machine has custom libicu like below.

The "custom" libicu is installed from the official source, because of another software that requires it.

Maybe it was because I tried to use the HPE version of LTFS? maybe it "messed up" with my environment?

Anyway, if that's the case, I'll just do the workaround of making the symlink.

Do you want me to check anything else?

piste2750 commented 2 years ago

Maybe it was because I tried to use the HPE version of LTFS? maybe it "messed up" with my environment?

I don't know the HPE's LTFS well, but it is not a fantasy that it modified the system environment automatically.

I assume you have following files. And also you have a symlink /usr/local/lib64/libltfs.so. It looks the configuration of the dynamic linker ld on your machine is not changed from default. lib64 directory is not configured on Ubuntu (RHEL uses that directory).

/usr/local/lib/libltfs.so.0 -> libltfs.so.0.0.0
/usr/local/lib/libltfs.la
/usr/local/lib/libltfs.so.0.0.0
/usr/local/lib/libltfs.so -> libltfs.so.0.0.0
/usr/local/lib/libltfs.a
/usr/local/lib/ltfs/libiosched-fcfs.so
/usr/local/lib/ltfs/libtape-sg.so
/usr/local/lib/ltfs/libtape-itdtimg.so
/usr/local/lib/ltfs/libkmi-flatfile.so
/usr/local/lib/ltfs/libiosched-unified.so
/usr/local/lib/ltfs/libtape-file.so
/usr/local/lib/ltfs/libkmi-simple.so

I have the configuration of ld like below. My machine is just install Ubuntu 18.04 and updated to the latest module by sudo apt-get -q -y update and sudo apt-get -q -y upgrade

$ cat /etc/ld.so.conf
include /etc/ld.so.conf.d/*.conf
$ ls /etc/ld.so.conf.d/
fakeroot-x86_64-linux-gnu.conf  libc.conf  x86_64-linux-gnu.conf
$ cat /etc/ld.so.conf.d/fakeroot-x86_64-linux-gnu.conf
/usr/lib/x86_64-linux-gnu/libfakeroot
$ cat /etc/ld.so.conf.d/libc.conf
# libc default configuration
/usr/local/lib
$ cat /etc/ld.so.conf.d/x86_64-linux-gnu.conf
# Multiarch support
/usr/local/lib/x86_64-linux-gnu
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
TyrasNistru commented 2 years ago

Think I found it, and looks like my guess was right. Looking at the /etc/ld.so.conf.d directory I found a HPE-SOS.conf file:

/usr/local/lib64
/usr/local/lib
TyrasNistru commented 2 years ago

Thanks SO much for your help @piste2750!

After removing the file and running ldconfig, now ldd reports that it is linking from /usr/local/lib directory!

I am now struggling with another problem (looks like it can't read anything from the tape device), but thats clearly outside the scope of this post.

Thanks again!