title: "undefined reference to 'cblas_ddot'" when using cblas library
body: <p>I was testing the cblas ddot, and the code I used is from the <a href="https://stackoverflow.com/questions/14470799/calling-ddot-function-in-blas-library">link</a> and I fixed it as</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;cblas.h&gt;
  
  int main()
  {
      double  m[10],n[10];
      int i;
      int result;
  
      printf("Enter the elements into first vector.\n");
      for(i=0;i&lt;10;i++)
          scanf("%lf",&amp;m[i]);
  
      printf("Enter the elements into second vector.\n");
      for(i=0;i&lt;10;i++)
          scanf("%lf",&amp;n[i]);
  
      result = cblas_ddot(10, m, 1, n, 1);
      printf("The result is %d\n",result);
  
      return 0;
  }
  </code></pre>
  
  <p>Then when I compiled it, it turned out to be:</p>
  
  <pre><code>/tmp/ccJIpqKH.o: In function `main':
  test.c:(.text+0xbc): undefined reference to `cblas_ddot'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>I checked the cblas file in <code>/usr/include/cblas.h</code>, and noticed there is</p>
  
  <pre><code>double cblas_ddot(const int N, const double *X, const int incX,
                const double *Y, const int incY);
  </code></pre>
  
  <p>I don't know where it is going wrong. Why does the compiler said the "cblas_ddot" is undefined reference? </p>