title: Link error Armadillo C++ Library with LAPACK, BLAS and GFortran undefined reference
body: <p>I am trying to compile Armadillo 4.300 using MinGW for Windows 32-bit using LAPACK and BLAS (compiled from source, downloaded from <a href="http://icl.cs.utk.edu/lapack-for-windows/lapack/" rel="nofollow">http://icl.cs.utk.edu/lapack-for-windows/lapack/</a> )</p>
  
  <p>I used the following cmake command to generate makefiles:</p>
  
  <pre><code>cmake -G "MSYS Makefiles" -D CMAKE_PREFIX_PATH=/c/msys/1.0 .
  </code></pre>
  
  <p>It finds liblapack.a and libblas.a as below:</p>
  
  <pre><code>-- Found a LAPACK library: c:/msys/1.0/lib/liblapack.a
  -- Found a BLAS library: c:/msys/1.0/lib/libblas.a
  </code></pre>
  
  <p>I get the following errors when running <code>make</code> straight out of the box:</p>
  
  <pre><code>c:/msys/1.0/lib/libblas.a(xerbla.f.obj):xerbla.f:(.text+0x70): undefined reference to `_gfortran_st_write'
  c:/msys/1.0/lib/libblas.a(xerbla.f.obj):xerbla.f:(.text+0x84): undefined reference to `_gfortran_string_len_trim'
  c:/msys/1.0/lib/libblas.a(xerbla.f.obj):xerbla.f:(.text+0xa4): undefined reference to `_gfortran_transfer_character_write'
  c:/msys/1.0/lib/libblas.a(xerbla.f.obj):xerbla.f:(.text+0xbd): undefined reference to `_gfortran_transfer_integer_write'
  c:/msys/1.0/lib/libblas.a(xerbla.f.obj):xerbla.f:(.text+0xc9): undefined reference to `_gfortran_st_write_done'
  c:/msys/1.0/lib/libblas.a(xerbla.f.obj):xerbla.f:(.text+0xd8): undefined reference to `_gfortran_stop_string'
  c:/tdm-gcc-64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: c:/msys/1.0/lib/libblas.a(xerbla.f.obj): bad reloc address 0x0 in section `.pdata'
  collect2.exe: error: ld returned 1 exit status
  make[2]: *** [libarmadillo.dll] Error 1
  make[1]: *** [CMakeFiles/armadillo.dir/all] Error 2
  make: *** [all] Error 2
  </code></pre>
  
  <p>When I add -lgfortran to the linker arguments in the file .\CMakeFiles\armadillo.dir\build.make it solves the above dependency to libgfortran.a but I get another error which I cannot resolve:</p>
  
  <pre><code>Linking CXX shared library libarmadillo.dll
  c:/msys/1.0/lib/liblapack.a(sgetrf.f.obj):sgetrf.f:(.text+0x4d3): undefined reference to `strsm_'
  c:/msys/1.0/lib/liblapack.a(dgetrf.f.obj):dgetrf.f:(.text+0x4d3): undefined reference to `dtrsm_'
  c:/msys/1.0/lib/liblapack.a(cgetrf.f.obj):cgetrf.f:(.text+0x4d3): undefined reference to `ctrsm_'
  c:/msys/1.0/lib/liblapack.a(zgetrf.f.obj):zgetrf.f:(.text+0x4cf): undefined reference to `ztrsm_'
  c:/msys/1.0/lib/liblapack.a(sgetri.f.obj):sgetri.f:(.text+0x730): undefined reference to `strsm_'
  c:/msys/1.0/lib/liblapack.a(sgetri.f.obj):sgetri.f:(.text+0x7d1): undefined reference to `sswap_'
  c:/tdm-gcc-64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: c:/msys/1.0/lib/liblapack.a(sgetri.f.obj): bad reloc address 0x0 in section `.pdata'
  collect2.exe: error: ld returned 1 exit status
  make[2]: *** [libarmadillo.dll] Error 1
  make[1]: *** [CMakeFiles/armadillo.dir/all] Error 2
  make: *** [all] Error 2
  </code></pre>
  
  <p>Where do I go from here?</p>