Shared object and dependencies - gfortran + Java

We have run into a peculiar problem with the combination gfortran and Java:

  • I have a shared object under Linux, built with a current version of gfortran. It worked before with an older version - this depended on libgfortran.so.3 and this dependency was shown by ldd.
  • Since I had to repair something about the code, I built it again with the newer version, but now the dependency on the gfortran runtime library does not show up. It turns out, however, that the shared object depends on libgfortran.so.5.
  • So far, so good. But the shared object is used by a Java program. It loads the dependencies explicitly, just as before, but now it fails to load the Fortran shared object, because it cannot find the routine _gfortran_st_read. This routine is, however, present in libgfortran.so.5.

My question is: how do we solve this?

I am not sure we still have the old GNU compiler, so that is probably not a solution (besides the Linux version has also changed). I have no clue as to why the dependency on the gfortran runtime library does not show up anymore - the strings utility cannot find any reference in the shared object, so no wonder that ldd cannot find it either.

The compile options are very straightforward, I have tried to use -static-libgfortran, but that seems to be misunderstood by the linker. Anyway, I am open to suggestions :slight_smile:

I found the solution! The cause was the use of gcc to invoke the linker instead of gfortran. I added the option -lgfortran to the link step and then the dependency showed up. And probably because of that it also worked fine in the Java program.