Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm not very knowledgeable on this topic, and therefore can't figure out why the following command does not work:

 $ gfortran -o dsimpletest -O  dsimpletest.o ../lib/libdmumps.a \ 
 ../lib/libmumps_common.a  -L/usr -lparmetis -lmetis -L../PORD/lib/ \
 -lpord -L/home/eiser/src/scotch_5.1.12_esmumps/lib -lptesmumps -lptscotch \
 -lptscotcherr /opt/scalapack/lib/libscalapack.a   -L/usr/lib/openmpi/ \ 
 -lmpi -L/opt/scalapack/lib/librefblas.a -lrefblas -lpthread
 /usr/bin/ld: cannot find -lrefblas
 collect2: ld returned 1 exit status

This happens when compiling the mumps library. The above command is executed by make. I've got the librefblas.a in the correct path:

$ ls /opt/scalapack/lib/ -l
total 20728
-rw-r--r-- 1 root root   619584 May  3 14:56 librefblas.a
-rw-r--r-- 1 root root  9828686 May  3 14:59 libreflapack.a
-rw-r--r-- 1 root root 10113810 May  3 15:06 libscalapack.a
-rw-r--r-- 1 root root   653924 May  3 14:59 libtmg.a

Question 1: I thought the -L switch of ld takes directories, why does it refer to the file directly here? If I remove the librefblas.a from the -L argument, I get a lot of "undefined reference" errors.

Question 2: -l should imply looking for .a and then looking for .so, if I recall correctly. Is it a problem that I don't have the .so file? I tried to find out by using gfortran -v ..., but this didn't help me debugging it.

share|improve this question
    
Are you sure gfortran searches that path? I don't know gfortran, but I'd first check set | grep PATH for anything looking useful. –  jippie May 4 '12 at 7:06
    
set | grep scala returns nothing. how can I add this path? –  Sebastian May 4 '12 at 7:20
    
I think your instinct to make the last -L a directory was correct. What symbols were undefined when you did that? –  ckhan May 4 '12 at 7:22
2  
If you get undefined references but no more "cannot find -lfoo", it means it found your libraries. But you're missing other libraries and/or got your link order wrong. Without seeing what undefined references you have, this question is unanswerable. –  Mat May 4 '12 at 7:26
1  
Try reordering the libraries, linking to refblas and then to mpi... I've no clue why but once it solved my problem when linking with gcc/ld! –  Huygens May 4 '12 at 11:28
show 1 more comment

1 Answer 1

up vote 1 down vote accepted

I was able to solve this with the help of the comments, particular credit to @Mat.

Since I wanted to compile the openmpi version, it helped to use mpif90 instead of gfortran, which, on my system, is

 $ mpif90 --showme
 /usr/bin/gfortran -I/usr/include -pthread -I/usr/lib/openmpi -L/usr/lib/openmpi -lmpi_f90 -lmpi_f77 -lmpi -ldl -lhwloc
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.