title: 'configure: error: cannot compile a simple Fortran program' with Fortran compiler installed
body: <p>I'm trying to install <a href="http://astro.dur.ac.uk/~jch/gadgetviewer/index.html" rel="noreferrer">gadgetviewer</a> on my macbook, however when I run</p>
  
  <pre><code>./configure prefix=/usr/local/bin
  </code></pre>
  
  <p>after a load of output I get:</p>
  
  <pre><code>checking for g_key_file_new in -lglib-2.0... no
  checking how to get verbose linking output from gfortran... configure: 
  WARNING: compilation failed
  
  checking for Fortran libraries of gfortran...
  checking for dummy main to link with Fortran libraries... none
  checking for Fortran name-mangling scheme... configure: error: in `/Users/chris/Downloads/gadgetviewer-1.0.7':
  configure: error: cannot compile a simple Fortran program 
  </code></pre>
  
  <p>But I have gfortran installed and working:</p>
  
  <pre><code>$ which gfortran
  /usr/local/bin/gfortran
  </code></pre>
  
  <p>Does anyone have any ideas why it can't seem to find the fortran compiler?</p>
  
  <p>Thanks as always.</p>
  
  <p>edi1:</p>
  
  <p>my path output is:</p>
  
  <pre><code>$ echo $PATH
  </code></pre>
  
  <p>/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/opt/ldg/bin:/opt/ldg/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Users/chris/.local/bin:/Applications/root_v6.06.06/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin</p>
  
  <p>(won't let me put that in a code block)</p>
  
  <p>In the <a href="http://astro.dur.ac.uk/~jch/gadgetviewer/README" rel="noreferrer">README</a> we have:</p>
  
  <pre><code>1.2 Specifying compilers and flags
  ----------------------------------
  
  The compilers to use can be specified by setting the following
  environment variables before running the configure script:
  
  CC      - C compiler
  CFLAGS  - C compiler flags
  FC      - Fortran 90 compiler
  FCFLAGS - Fortran compiler flags
  </code></pre>
  
  <p>and my config.log file has in it:</p>
  
  <pre><code>CC='gcc'
  CFLAGS='-g -O2'
  ...
  CPP='gcc -E'
  CPPFLAGS=''
  ...
  FC='gfortran'
  FCFLAGS=''
  FCFLAGS_f90=''
  </code></pre>
  
  <p>where I have ommitted some of the information I don't think is relevant. So the C compiler has flags and the fortran one does not, perhaps this is relevant? I'm totally clueless as to what's going on here (pretty new to installing stuff like this).</p>
  
  <p>edit2:</p>
  
  <p>Also just found this is on the config.log:</p>
  
  <pre><code>configure:19184: checking how to get verbose linking output from gfortran
  configure:19200: gfortran -c   conftest.f &gt;&amp;5
  ./configure: line 19202: /usr/local/bin/gfortran: Bad CPU type in executable
  configure:19207: $? = 126
  configure: failed program was:
  |       program main
  |
  |       end
  configure:19291: WARNING: compilation failed
  configure:19298: result:
  configure:19300: checking for Fortran libraries of gfortran
  configure:19323: gfortran -o conftest conftest.f -lz -lm
  ./configure: line 19327: /usr/local/bin/gfortran: Bad CPU type in executable
  configure:19500: result:
  configure:19515: checking for dummy main to link with Fortran libraries
  configure:19559: gcc -o conftest -g -O2   conftest.c -lz -lm   &gt;&amp;5
  configure:19566: $? = 0
  configure:19654: result: none
  configure:19692: checking for Fortran name-mangling scheme
  configure:19711: gfortran -c   conftest.f &gt;&amp;5
  ./configure: line 19713: /usr/local/bin/gfortran: Bad CPU type in executable
  configure:19718: $? = 126
  configure: failed program was:
  |       subroutine foobar()
  |       return
  |       end
  |       subroutine foo_bar()
  |       return
  |       end
  configure:19920: error: in `/Users/chris/Downloads/gadgetviewer-1.0.7':
  configure:19923: error: cannot compile a simple Fortran program
  </code></pre>