This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

What is the correct way to use libamath and libastring?

Hello,

I am trying to integrate libamath.so (and libastring.so) in my program. But it seems that libm.so is used instead. I link the shared libraries something like this:

$ gfortran -shared -L~/proj/lib -fPIC -lastring -lamath -lm -o ~/proj/lib/libmylib.so ~/data/proj/obj/myobj.o -lmy_archive

Then I run the program:

$ LD_DEBUG=bindings ~/proj/bin/myprog 1>/tmp/foo.txt 2>/tmp/foo.txt

And examining the bindings I get:

$ cat /tmp/foo.txt | grep log10 | grep libgfortran
   2465474:     binding file ~/proj/lib/libgfortran.so.5 [0] to /lib/aarch64-linux-gnu/libm.so.6 [0]: normal symbol `log10l' [GLIBC_2.17]
   2465474:     binding file ~/proj/lib/libgfortran.so.5 [0] to /lib/aarch64-linux-gnu/libm.so.6 [0]: normal symbol `log10' [GLIBC_2.17]
   2465474:     binding file ~/proj/lib/libgfortran.so.5 [0] to /lib/aarch64-linux-gnu/libm.so.6 [0]: normal symbol `log10f' [GLIBC_2.17]

Why isn't libamath.so used? If I preload it, then it appears to be used:

$ LD_DEBUG=bindings LD_PRELOAD=~/proj/lib/libamath.so ~/proj/bin/myprog 1>/tmp/foo.txt 2>/tmp/foo.txt

$ cat /tmp/foo.txt | grep log10 | grep libgfortran
   2463666:     binding file ~/proj/lib/libgfortran.so.5 [0] to /lib/aarch64-linux-gnu/libm.so.6 [0]: normal symbol `log10l' [GLIBC_2.17]
   2463666:     binding file ~/proj/lib/libgfortran.so.5 [0] to ~/proj/lib/libamath.so [0]: normal symbol `log10' [GLIBC_2.17]
   2463666:     binding file ~/proj/lib/libgfortran.so.5 [0] to ~/proj/lib/libamath.so [0]: normal symbol `log10f' [GLIBC_2.17]

What am I doing wrong?