<p>I'm compiling library for a private project, which depends on a number of libraries. Specifically one of the dependencies is compiled with Fortran. On some instances, I've seen the dependency compiled with <code>g77</code>, on others I've seen it compiled with <code>gfortran</code>. My project then is <code>./configure</code>'d to link with either <code>-lg2c</code> or <code>-lgfortran</code>, but so far I've been doing it by hand.</p>

<p>If it is possible, how can I find out, from looking into the dependent library (via e.g. <code>nm</code> or some other utility?), whether the used compiler was <code>g77</code> (and then I'll use <code>-lg2c</code> in my link options) or <code>gfortran</code> (and then I'll use <code>-lgfortran</code>)?</p>

<p>Thanks in advance!</p>

You might be able to figure it out by using nm, and seeing if the compiled code uses functions from one or the other, but that's quite a hack.  You may be able to figure it out based on which library is available (if there's no libg2c available, then it wasn't g77, for example), but then you still have some ambiguity if both are available.  If you can build the dependency yourself, then you can use have one part of your build process tell another part somehow (variable, file, etc.) which one you used.