Alright. So get this...
I started again from scratch, after having replaced ranlib with echo. Before even having to manually ar -cr anything, (just for the heck of it) I entered:
gfortran test.f -L/path/to/lapack-3.4.0/ -llapack -lblas
...and my program compiled. Then, using the simple test code here
as my test program, I did the same thing, ran the program, and got the output I expected. However, when I run this slightly different command, as I have been all the while:
gfortran -L/path/to/lapack-3.4.0/ -llapack -lblas test.f
I get the familiar error:
/tmp/cckXpnoH.o: In function `MAIN__':
test.f:(.text+0xa6): undefined reference to `sgesv_'
collect2: ld returned 1 exit status
So. I guess it never occurred to me that this would make a difference, and who knows how long ago (how far back in this thread) I could have tried that and it would have worked. I'd rather not know, frankly. But I want to thank you both for all your help, you've been fantastic. Is this not unusual behaviour though? Why should it matter where in the flag sequence the linking commands are? In the past, I've linked libraries before entering the name of the program to be compiled, and it's worked fine (also very convenient, since I can just alias a big long string of flags and links into a simple command like "gfort", and then type gfort test.f). Any final thoughts? Thank you so much, again!