I had try to install openmpi 1.8.1 from the source code at Ubuntu 14.04 server. I would like to use mpi for large scale calculation on single machine with multi cores.
The simple "Hello world" test can be run without any problem.
However, when I trying to compile the program which I need to use. I got the following error:
/usr/bin/ld: cannot find -lmpi_usempi
/usr/bin/ld: cannot find -lmpi_mpifh
/usr/bin/ld: cannot find -lmpi
collect2: error: ld returned 1 exit status
make: *** [mcp2_mpi] Error 1
I had try to set the LD_LIBRAY_PATH to the directory where the openmpi lib can be find.
It seems doesn't work. I had try to check the ld command in verbose mode.
$ ld -lmpi_usempi --verbose
attempt to open /usr/x86_64-linux-gnu/lib64/libmpi_usempi.so failed
attempt to open /usr/x86_64-linux-gnu/lib64/libmpi_usempi.a failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libmpi_usempi.so failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libmpi_usempi.a failed
attempt to open //usr/local/lib64/libmpi_usempi.so failed
attempt to open //usr/local/lib64/libmpi_usempi.a failed
attempt to open //lib/x86_64-linux-gnu/libmpi_usempi.so failed
attempt to open //lib/x86_64-linux-gnu/libmpi_usempi.a failed
attempt to open //lib64/libmpi_usempi.so failed
attempt to open //lib64/libmpi_usempi.a failed
attempt to open //usr/lib/x86_64-linux-gnu/libmpi_usempi.so failed
attempt to open //usr/lib/x86_64-linux-gnu/libmpi_usempi.a failed
attempt to open //usr/lib64/libmpi_usempi.so failed
attempt to open //usr/lib64/libmpi_usempi.a failed
attempt to open //usr/local/lib/libmpi_usempi.so failed
attempt to open //usr/local/lib/libmpi_usempi.a failed
attempt to open //lib/libmpi_usempi.so failed
attempt to open //lib/libmpi_usempi.a failed
attempt to open //usr/lib/libmpi_usempi.so failed
attempt to open //usr/lib/libmpi_usempi.a failed
ld: cannot find -lmpi_usempi
It seems the ld doesn't look for the libraries in the LD_LIBRARY_PATH.
I had try to create a file in /etc/ld.so.conf.d/ to include the path of openmpi lib. Then the command sudo ldconfig -v. I find the following output:
/usr/local/openmpi/lib:
libopen-rte.so.7 -> libopen-rte.so.7.0.3
libmpi_mpifh.so.2 -> libmpi_mpifh.so.2.3.0
libopen-trace-format.so.1 -> libopen-trace-format.so.1.0.0
libmpi_cxx.so.1 -> libmpi_cxx.so.1.1.3
liboshmem.so.1 -> liboshmem.so.1.0.0
libvt-mpi.so.0 -> libvt-mpi.so.0.0.0
libvt-hyb.so.0 -> libvt-hyb.so.0.0.0
libvt-mt.so.0 -> libvt-mt.so.0.0.0
libotfaux.so.0 -> libotfaux.so.0.0.0
libvt-mpi-unify.so.0 -> libvt-mpi-unify.so.0.0.0
libopen-pal.so.6 -> libopen-pal.so.6.1.1
libmpi_usempi.so.1 -> libmpi_usempi.so.1.3.0
libmpi.so.1 -> libmpi.so.1.5.0
libvt.so.0 -> libvt.so.0.0.0
libmca_common_sm.so.4 -> libmca_common_sm.so.4.0.3
libompitrace.so.0 -> libompitrace.so.0.0.0
It seems the Libs are included in the ld search path.
However, I still got the same problem like before.
/usr/bin/ld: cannot find -lmpi_usempi
/usr/bin/ld: cannot find -lmpi_mpifh
/usr/bin/ld: cannot find -lmpi
collect2: error: ld returned 1 exit status
make: *** [mcp2_mpi] Error 1
Is there some suggestions to this issue? Thank you very much.
Best Answer
The steps you've tried affect the run time library search path. Assuming that you are using
gcc
, to set the compile time search path you need to use the compiler's-L
flagSo for example if you have installed the libraries into /usr/local/openmpi/lib, modify your
gcc
command line to