title: gcc linking error: /usr/bin/ld: undefined reference to symbol 'dnrm2_'
body: <p>I am trying to compile a Fortran program call ShengBTE. It uses a make file whose content is as follows -</p>
  
  <pre><code>export FC=gfortran
  export FFLAGS=-gfortran -g -O2 -fPIC  -fbounds-check
  export CFLAGS=-I/home/user/local/include
  export LDFLAGS=-L/usr/lib64/ -llapack -lgfortran
  </code></pre>
  
  <p>When I run make from the root folder I get the following error -</p>
  
  <pre><code>gfortran -g -O2 -fPIC  -fbounds-check -o ../ShengBTE conductivity.o config.o data.o input.o iterations.o misc.o gruneisen.o phonon_routines.o integrals.o processes.o scaling.o symmetry.o wedgetc.o ShengBTE.o -L/usr/lib64/ -llapack -lgfortran 
  /usr/bin/ld: conductivity.o: undefined reference to symbol 'dnrm2_'
  /usr/bin/ld: note: 'dnrm2_' is defined in DSO /usr/lib64/libblas.so.3 so try adding it to the linker command line
  /usr/lib64/libblas.so.3: could not read symbols: Invalid operation
  collect2: ld returned 1 exit status
  make: [../ShengBTE] Error 1 (ignored)
  </code></pre>
  
  <p>The libblas.so.3 exists under /usr/lib64 and should be available to the linker with the -L option in the make file. </p>
  
  <pre><code>ls /usr/lib64/libblas*
  lrwxrwxrwx 1     23 Apr 17 15:11 /usr/lib64/libblas.so -&gt; /usr/lib64/libblas.so.3*
  lrwxrwxrwx 1     30 Jun 27  2013 /usr/lib64/libblas.so.3 -&gt; /etc/alternatives/libblas.so.3*
  -rwxr-xr-x 1 362704 Mar 20  2013 /usr/lib64/libblas.so.3.4.2*
  </code></pre>
  
  <p>I read somewhere that gcc can be picky about the order in which files are linked. How do I change that through the make file?</p>