title: Unable to link to libgfortran.a
body: <p>I have gfortran installed on my system and the file <code>libgfortran.a</code> can be found at <code>/usr/lib/gcc/x86_64-linux-gnu/4.6/</code>. Using <code>nm</code> I made sure that the function <code>_gfortran_compare_string</code> is defined in there:</p>
  
  <pre><code>$ nm /usr/lib/gcc/x86_64-linux-gnu/4.6/libgfortran.a | grep _gfortran_compare_string
  </code></pre>
  
  <p>Returns</p>
  
  <pre><code>0000000000000000 T _gfortran_compare_string
  0000000000000000 T _gfortran_compare_string_char4
  </code></pre>
  
  <p>But, the linker of my CUDA-C program throws errors:</p>
  
  <pre><code>/usr/local/cuda-6.0/bin/nvcc --cudart static -L/usr/lib/gcc/x86_64-linux-gnu/4.6 -L/home/chung/lapack-3.5.0 -link -o  "pQP"  ./src/pQP.o   -lgfortran -llapacke -llapack -lcublas -lblas -lcurand
  nvcc warning : The 'compute_10' and 'sm_10' architectures are deprecated, and may be removed in a future release.
  /home/chung/lapack-3.5.0/liblapack.a(ilaenv.o): In function `ilaenv_':
  ilaenv.f:(.text+0x81): undefined reference to `_gfortran_compare_string'
  </code></pre>
  
  <p>and later on another error, again related to libgfortran:</p>
  
  <pre><code>/home/chung/lapack-3.5.0/liblapack.a(xerbla.o): In function `xerbla_':
  xerbla.f:(.text+0x49): undefined reference to `_gfortran_st_write'
  xerbla.f:(.text+0x54): undefined reference to `_gfortran_string_len_trim'
  xerbla.f:(.text+0x66): undefined reference to `_gfortran_transfer_character_write'
  xerbla.f:(.text+0x76): undefined reference to `_gfortran_transfer_integer_write'
  xerbla.f:(.text+0x7e): undefined reference to `_gfortran_st_write_done'
  xerbla.f:(.text+0x87): undefined reference to `_gfortran_stop_string'
  </code></pre>
  
  <p>But, again using nm, I found that <code>_gfortran_st_write</code>, etc are defined in libgfortran.a.</p>
  
  <p>Links: <a href="https://gist.github.com/alphaville/0e2342b2e85c8b5ab33f" rel="nofollow">Complete log</a> and <a href="https://github.com/alphaville/pQP" rel="nofollow">source code</a>.</p>
  
  <p><strong>Note:</strong> Lapack makes use of libgfortran. I recently installed lapack and ran all the tests and they all passed.</p>