Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

LAPACK for Fortran under Cygwin

  1. Dec 7, 2009 #1
    I just installed LAPACK, but I'm not sure how to use it. The documentation tells about the routines, but the problem is my compiler isn't recognizing them.

    For example...I wrote a simple Fortran program to test a routine (SGESV):

    Code (Text):

          program testlapack
              implicit  none

              integer N
              integer NRHS
              integer LDA
              integer IPIV(N)
              integer LDB
              real A(LDA,N)
              real B(LDB,NRHS)
              integer INFO
              external SGESV

              call SGESV(N,NRHS,A,LDA,IPIV,B,LDB,INFO)

    Then I compile in and it fails...

    Code (Text):

    $ g77 -ff90 -o test test.for
    /cygdrive/c/Users/david/AppData/Local/Temp/ccU0lt1W.o:test.for:(.text+0x4e): undefined reference to `_sgesv_'
    collect2: ld returned 1 exit status
    Is there something line an "include" or "use" statement that I have to include in my code file so the compiler will recognize these LAPACK routines?

  2. jcsd
  3. Dec 7, 2009 #2
    I seem to have found a solution by specifying a linker flag:

    Code (Text):
    $ g77 -ff90 -o test test.for -llapack
  4. Dec 7, 2009 #3


    User Avatar
    Science Advisor

    Yup, that's how you link to a library.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook