MPI-加载共享库时出错 [英] MPI - error loading shared libraries

查看:416
本文介绍了MPI-加载共享库时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的问题已在这里解决: 在open-mpi/mpi-run中加载共享库

The problem I faced has been solved here: Loading shared library in open-mpi/ mpi-run

我不知道如何设置我的安装本身指定必要的-L参数,从而设置LD_LIBRARY_PATH或指定-x LD_LIBRARY_PATH可以解决此问题.我的安装在~/mpi/

I know not how, setting LD_LIBRARY_PATH or specifying -x LD_LIBRARY_PATH fixes the problem, when my installation itself specifies the necessary -L arguments. My installation is in ~/mpi/

我还包括了我的编译链接配置.

I have also included my compile-link configs.

$ mpic++ -showme:version 
mpic++: Open MPI 1.6.3 (Language: C++)

$ mpic++ -showme
g++ -I/home/vigneshwaren/mpi/include -pthread -L/home/vigneshwaren/mpi/lib
-lmpi_cxx -lmpi -ldl -lm -Wl,--export-dynamic -lrt -lnsl -lutil -lm -ldl

$ mpic++ -showme:libdirs
/home/vigneshwaren/mpi/lib

$ mpic++ -showme:libs
mpi_cxx mpi dl m rt nsl util m dl    % Notice mpi_cxx here %

当我使用mpic++ <file>编译并使用mpirun a.out运行时,出现了(共享库)链接器错误

When I compiled with mpic++ <file> and ran with mpirun a.out I got a (shared library) linker error

error while loading shared libraries: libmpi_cxx.so.1: 
cannot open shared object file: No such file or directory

已通过设置LD_LIBRARY_PATH修复了该错误.问题是如何以及为什么?我想念什么?当我的安装看起来很好时,为什么需要LD_LIBRARY_PATH.

The error has been fixed by setting LD_LIBRARY_PATH. The question is how and why? What am i missing? Why is LD_LIBRARY_PATH required when my installation looks just fine.

推荐答案

libdllibmlibrtlibnsllibutil都是系统范围内必不可少的库,它们是非常基本的操作系统安装. libmpilibmpi_cxx是Open MPI安装的一部分,在您情况下,它们位于非标准位置,必须在链接器搜索路径LD_LIBRARY_PATH中明确包含这些位置.

libdl, libm, librt, libnsl and libutil are all essential system-wide libraries and they come as part of the very basic OS installation. libmpi and libmpi_cxx are part of the Open MPI installation and in your case are located in a non-standard location that must be explicitly included in the linker search path LD_LIBRARY_PATH.

可以修改Open MPI编译器包装的配置,并使它们将-rpath选项传递给链接程序. -rpath采取库路径并将其追加到存储在可执行文件中的列表中,该列表在查询LD_LIBRARY_PATH变量之前告诉运行时链接编辑器(也称为动态链接器)在何处搜索库.例如,在您的情况下,以下选项就足够了:

It is possible to modify the configuration of the Open MPI compiler wrappers and make them pass the -rpath option to the linker. -rpath takes a library path and appends its to a list, stored inside the executable file, which tells the runtime link editor (a.k.a. the dynamic linker) where to search for libraries before it consults the LD_LIBRARY_PATH variable. For example, in your case the following option would suffice:

-Wl,-rpath,/home/vigneshwaren/mpi/lib

这将在可执行文件中嵌入Open MPI库的路径,并且在运行时该路径是否是LD_LIBRARY_PATH的一部分都没有关系.

This would embed the path to the Open MPI libraries inside the executable and it would not matter if that path is part of LD_LIBRARY_PATH at run time or not.

要使相应的包装器将该选项添加到编译器标志列表中,您必须修改mpiXX-wrapper-data.txt文件(其中XXccc++CCf90,等),位于mpi/share/openmpi/中.例如,要使mpicc通过该选项,您将必须修改/home/vigneshwaren/mpi/share/openmpi/mpicc-wrapper-data.txt并将以下内容添加到以linker_flags=开头的行:

To make the corresponding wrapper add that option to the list of compiler flags, you would have to modify the mpiXX-wrapper-data.txt file (where XX is cc, c++, CC, f90, etc.), located in mpi/share/openmpi/. For example, to make mpicc pass the option, you would have to modify /home/vigneshwaren/mpi/share/openmpi/mpicc-wrapper-data.txt and add the following to the line that starts with linker_flags=:

linker_flags= ... -Wl,-rpath,${prefix}/lib

包装程序会自动将

${prefix}扩展到当前的Open MPI安装路径.

${prefix} is automatically expanded by the wrapper to the current Open MPI installation path.

这篇关于MPI-加载共享库时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆