LAPACK for Fortran under Cygwin

  • Thread starter Thread starter Bill Foster
  • Start date Start date
  • Tags Tags
    Fortran Lapack
Click For Summary
SUMMARY

The discussion focuses on using LAPACK with Fortran under the Cygwin environment. The user encountered a linking error when attempting to compile a Fortran program that utilizes the SGESV routine. The solution involved adding the linker flag "-llapack" during the compilation process, which successfully linked the LAPACK library to the program. This highlights the importance of correctly linking external libraries in Fortran applications.

PREREQUISITES
  • Familiarity with Fortran programming language
  • Understanding of LAPACK routines and their usage
  • Knowledge of Cygwin environment setup
  • Experience with compiler flags and linking libraries
NEXT STEPS
  • Research LAPACK documentation for additional routines and their applications
  • Learn about linking libraries in Fortran with different compilers
  • Explore advanced LAPACK functionalities for solving linear algebra problems
  • Investigate Cygwin configuration for optimizing Fortran compilation
USEFUL FOR

Fortran developers, numerical analysts, and anyone working with LAPACK in a Cygwin environment will benefit from this discussion.

Bill Foster
Messages
334
Reaction score
0
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:
      program testlapack
          implicit  none

          integer N
          parameter(N=10)
          integer NRHS
          parameter(NRHS=1)
          integer LDA
          parameter(LDA=10)
          integer IPIV(N)
          integer LDB
          parameter(LDB=N)
          real A(LDA,N)
          real B(LDB,NRHS)
          integer INFO
          external SGESV

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

       end

Then I compile in and it fails...

Code:
$ 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?

Thanks.
 
Physics news on Phys.org
I seem to have found a solution by specifying a linker flag:

Code:
$ g77 -ff90 -o test test.for -llapack
 
Yup, that's how you link to a library.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
8K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 18 ·
Replies
18
Views
7K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 5 ·
Replies
5
Views
10K
  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 8 ·
Replies
8
Views
8K