How to find out which compiler was used: g77 or gfortran

I am compiling a library for a private project, which depends on a number of libraries. In particular, one of the dependencies is compiled using Fortran. In some cases, I saw a dependency compiled with g77 ; on others that I saw, it was compiled with gfortran . My project then ./configure 'd to communicate with -lg2c or -lgfortran , but so far I have done this manually.

If possible, how can I find out by looking at a dependent library (e.g. nm or some other utility?), Was the g77 compiler used (and then I will use -lg2c in my link options) or gfortran (and then I will -lgfortran use -lgfortran )?

Thanks in advance!

+7
gfortran g77
source share
3 answers
 nm filename | fgrep ' __g77' 

will give results if g77 was used, meanwhile

 nm filename | fgrep '@@GFORTRAN' 

will give results if gfortran is used.

+6
source share

You need grep for something, the output of nm filename , which indicates whether g77 or gfortran were used. In most cases, if the library performs at least one I / O in one place, it calls libg2c or libgfortran, and you will notice a symbol with g77 in it or gfortran . So the best way is to use grep:

 nm filename | grep _g77_ nm filename | grep _gfortran_ 

Two notes:

  • Grepping for @@GFORTRAN , because the proposed geocard is not reliable: it will only work on platforms that support library version support, which includes, for example, Linux, but not Windows or Mac OS.
  • It is still possible that some compiled code absolutely does not support the library support function (if everything that it does is simple arithmetic and does not have I / O, for example). In this case, if it is not compiled with debugging options, it is impossible to determine which compiler outputs it.
+3
source share

You may be able to figure this out with nm and see if the compiled code uses functions from one or the other, but it's pretty hack. You may be able to figure out which library (if libg2c is not there, then it is not g77, for example), but then you still have some ambiguity, if available. If you can build the dependency yourself, then you can use one part of your build process to somehow indicate the other part (variable, file, etc.) that you used.

+1
source share

All Articles