c++ - 如何构建静态 C++ openmpi 应用程序?
问题描述
我想做的是为 Linux 机器生成一个静态 MPI 可执行文件。源代码是用 C++ 编写的。当我编译代码的串行版本时,使用gcc -static
, 并ldd
在可执行文件上运行它显示没有库。
但是,当我使用 MPI 尝试此操作时,某些库没有被静态链接。我已经在我的机器上构建了我的 openmpi,请参见下面的 shell 命令。我还看到,没有与可执行文件静态链接的完全相同的库也没有静态链接到 openmpi 构建。在 openmpi 构建结束时,我得到
/home/bevan/Downloads/openmpi-4.0.1/opal/.libs/libopen-pal.a(dl_dlopen_module.o): In function `dlopen_open':
dl_dlopen_module.c:(.text+0x413): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/bevan/Downloads/openmpi-4.0.1/orte/.libs/libopen-rte.a(plm_rsh_module.o): In function `setup_launch':
plm_rsh_module.c:(.text+0xca2): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/bevan/Downloads/openmpi-4.0.1/opal/.libs/libopen-pal.a(if.o): In function `opal_ifaddrtoname':
if.c:(.text+0x1e4): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/bevan/Downloads/openmpi-4.0.1/orte/.libs/libopen-rte.a(ras_slurm_module.o): In function `init':
ras_slurm_module.c:(.text+0x6e4): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/bevan/Downloads/openmpi-4.0.1/opal/.libs/libopen-pal.a(evutil.o): In function `evutil_unparse_protoname':
/home/bevan/Downloads/openmpi-4.0.1/opal/mca/event/libevent2022/libevent/evutil.c:758: warning: Using 'getprotobynumber' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
我觉得我应该使用的那种命令链是,
tar -xvf openmpi-4.0.1
cd ./openmpi-4.0.1
./configure --prefix="$HOME/.openmpi" --without-memory-manager CXX=g++ CC=gcc LDFLAGS=--static --disable-shared --enable-static
make
sudo make install
export PATH="$PATH:$HOME/.openmpi/bin"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/.openmpi/lib/"
cd application/directory/build
cmake ..
make application
我希望能够ldd application
在使用 MPI 编译后运行,并且没有与应用程序关联的动态链接库。
解决方案
推荐阅读
- object - Blender 中的动画对象未正确/奇怪地沿边缘旋转(参见视频)
- javascript - 有没有一种方法可以使用 JavaScript / jQuery 将当前时间与视频时间同步?
- php - 以富有想象力的显示运行 shell 命令
- python - python 2.7 list ,我不明白的东西
- firebase - 如何从 Firebase 动态检索数据?
- javascript - 如何将关闭按钮添加到我的灯箱?所以我可以从按钮关闭图片,而不是单击灯箱中的任何位置
- python - 当我尝试从 python 中的 pandas 数据框创建新列时,部分关键字匹配不起作用?
- spring-boot - 即使在声明 @DynamoDBRangeKey(attributeName = "") 之后,dynamoDB spring boot 应用程序中的错误“no RANGE key value present”
- r - stat=identity 在 geom_bar ggplot 中究竟是什么意思?
- css - React CSS 重复