title: How do I fix "undefined reference to _gfortran_set_std" errors when compiling a simple Fortran program?
body: <p>I'm trying to compile a simple Fortran program, called <code>sandbox.for</code>:</p>
  <pre><code>program sandbox
      implicit none
      integer, parameter :: dp = kind(1.0d0)
      real(dp), dimension(2, 2) :: a
      integer :: i
  
      a = reshape([1, 2, 1, 2], shape(a))
      do i=1,2
          print *, a(i, :)
      end do
  
  end program sandbox
  </code></pre>
  <p>I attempted to compile the program using <code>gfortran -ffree-form -o sandbox sandbox.for</code>, but I get the following error:</p>
  <pre><code>/tmp/ccylnLGH.o: In function `MAIN__': sandbox.for:(.text+0x1b):
  undefined reference to `_gfortran_set_std' collect2: ld returned 1
  exit status
  </code></pre>
  <p>I found an <a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2008-November/018266.html" rel="nofollow noreferrer">old post</a> that says this might be related to an old version of gcc. I'm running gfortran/gcc 4.1.2 on CentOS 5.9 Final. The mailing post suggests compiling a newer version of gcc and installing it, but I don't have root privileges on the system so I can't install newer software. I believe that on this system (it's a server at work), gfortran was installed from the repository and is kept up to date that way.</p>
  <p>Is this error related to the version of gcc and gfortran that I'm using, or is there another problem?</p>
  <h3>More info</h3>
  <p>The output of <code>yum list | grep libgfortran</code> is this, if it helps:</p>
  <pre><code>libgfortran.i386                   4.1.2-54.el5            installed
  libgfortran.x86_64                 4.1.2-54.el5            installed
  libgfortran44.i386                 4.4.7-1.el5             base     
  libgfortran44.x86_64               4.4.7-1.el5             base
  </code></pre>