Fortran What causes undefined reference errors in gfortran compilation?

  • Thread starter Thread starter SAks
  • Start date Start date
  • Tags Tags
    Gfortran
AI Thread Summary
The user is encountering compilation issues with Fortran while trying to link the BLAS library. The initial error indicates that the linker cannot find the BLAS library, suggesting it may not be installed or is located in a non-standard directory. To resolve this, the user is advised to specify the library's directory using the -L option followed by the full path. After attempting this, a new error arises related to an undefined reference to `MAIN__`, indicating a potential issue with the main program structure in the Fortran code or missing required components. Further troubleshooting is needed to address the undefined reference error.
SAks
Messages
6
Reaction score
0
Hi friends!
I am a complete newbie to fortran..
I've been trying to compile linpack but keep getting following error..

[SAks@localhost Desktop]$ gfortran schdc.f -lblas
/usr/bin/ld: cannot find -lblas
collect2: ld returned 1 exit status


please advise..

Thanks in advance
 
Technology news on Phys.org
It means that the 'blas' library either is not installed, or is not in the location where the compiler (actually the linker) expects to find it.

If that library is in a non-standard location, e.g. /foo/bar/blas.a or /foo/bar/blas.dylib or whatever filename extension your OS uses for libraries, then you can tell the linker to search the directory /foo/bar for libraries, in addition to wherever it already searches:

gfortran schdc.f -L/foo/bar -lblas

You might have to add a slash: -L/foo/bar/ (it's been a long time since I had to do this)

The main thing is to give the full directory path.
 
@jtbell
thanks for responding..
I did give the whole path, now some new problem..
this is what i get..

[SAks@localhost Desktop]$ gfortran schdc.f -L/home/SAks/Desktop -lblas
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgfortranbegin.a(fmain.o): In function `main':
(.text+0x26): undefined reference to `MAIN__'
collect2: ld returned 1 exit status
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
6
Views
2K
Replies
9
Views
9K
Replies
5
Views
10K
Replies
16
Views
6K
Replies
4
Views
7K
Replies
3
Views
12K
Replies
6
Views
2K
Back
Top