compilation fails for tests due to undefined references

Issue #72 resolved
Ryusuke Numata created an issue

On one of my linux environment, compilation fails for tests due to undefined references as shown in the attached file. This problem can be avoided by adding -lgs2 in LIBS (see branch bugfix/fix-link-order). I wonder if this change may cause a problem on other systems.

I don't know why this problem occurs on one system (Linux+Intel/18.0.2) while it doesn't on my other environments.

Comments (9)

  1. David Dickinson

    That is definitely strange, I think the missing symbols should be provided by the -lsimpledataio that is in the link line (and after the existing -lgs2, which I think is correct). If you have a fix we can obviously look at including that, but it would be good if we can understand why this has happened. Perhaps @ZedThree has some ideas?

  2. Ryusuke Numata reporter

    If I replace h5pfc with ifort, it works. So, the problem comes from h5pfc. I looked at the detail of the link command launched by h5pfc, and found that h5pfc rearranges the order of the archive files. It moves .a file to the end of the command line maybe because it wants to put the archive files of hdf5 at the end.

    See the attached logs of ifort and h5pfc output with "-v" option.

    I'll further investigate the hdf5 installation to see why this happens.

  3. Ryusuke Numata reporter

    It turns out that h5pfc always rearrange the order of .a file. I've confirmed this on my mac.
    I've compared the behavior of ifort (on linux) and gfortran (on mac), and have found only ifort cares the order of library.
    (or, more precisely, gfortran on my mac does not care about the order of libraries.)

  4. Ryusuke Numata reporter

    I have two linux hosts where the link order matters using GNU ld v2.2?.
    On mac, the link order does not matter for ld (LLVM 10.0.0).
    On other hosts, the problem does not appear just because h5pfc is not used. (Insted, the options specifying hdf5 libraries are given.)

    So, I guess this problem happens

    • if one uses h5pfc/h5fc script
    • if linker cares the order of libraries
  5. Ryusuke Numata reporter

    I wonder why the gs2 library is linked like an object file libgs2.a rather than a library (-lgs2) in tests.

  6. David Dickinson

    That's a good question, I suspect we can indeed use -lgs2 (possibly after specifying -L/path/to/lib).

  7. Log in to comment