mpi - Boost.MPI问题

标签 mpi build-error boost-mpi

我正在开发 HPC。在该 HPC 上安装了旧版本的 Boost,并且该 boost 库没有 Boost.MPI。我请求管理员将其安装在 HPC 上。但他们要求我将其安装在我的主目录中。所以我在我的主目录中安装了 boost 和 boost.mpi 。 Boost 库似乎工作正常。但是当我尝试使用下面的命令运行以下代码时,出现错误。

测试代码:

#include <boost/mpi/environment.hpp>
#include <boost/mpi/communicator.hpp>
#include <iostream>
namespace mpi = boost::mpi;

int main(int argc, char* argv[]) 
{
  mpi::environment env(argc, argv);
  mpi::communicator world;
  std::cout << "I am process " << world.rank() << " of " << world.size()
        << "." << std::endl;
  return 0;
}

构建命令:

 mpiCC -I/home1/username/boost/include 
-I/usr/mpi/gcc/openmpi-1.2.8/include/
-L/home1/username/boost/lib 
-L/usr/mpi/gcc/openmpi-1.2.8/lib64/openmpi 
-lboost_mpi-gcc-mt-1_35  testboostmpi2.cpp

我收到以下错误尖叫:

testboostmpi2.o: In function `main':
testboostmpi2.cpp:(.text+0x59): undefined reference to     
`boost::mpi::environment::environment(int&, char**&, bool)'
testboostmpi2.cpp:(.text+0x63): undefined reference to 
`boost::mpi::communicator::communicator()'
 testboostmpi2.cpp:(.text+0x86): undefined reference to 
`boost::mpi::environment::~environment()'
testboostmpi2.cpp:(.text+0xb9): undefined reference to 
`boost::mpi::environment::~environment()'

如果你们能提供帮助,我将非常感激。

最佳答案

假设您使用的是 g++,您可以尝试使用 -Wl,--rpath 链接器选项。

mpiCC testboostmpi2.cpp -I/home1/username/boost/include-I/usr/mpi/gcc/openmpi-1.2.8/include/ \
    -L/home1/username/boost/lib -L/usr/mpi/gcc/openmpi-1.2.8/lib64/openmpi \
    -lboost_mpi-gcc-mt-1_35 -Wl,-rpath -Wl,/home1/username/boost/lib \
    -Wl,-rpath -Wl,/usr/mpi/gcc/openmpi-1.2.8/lib64/openmpi

还要以正确的顺序链接,您需要将源文件作为第一个参数,而不是最后一个。

关于mpi - Boost.MPI问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1538535/

相关文章:

cmake - 如何让 cmake 查找第三方头文件 mpi.h 中类型的大小?

python - 新安装的 Fenics 演示在 MPICH_NUMVERSION 上崩溃

c++ - 如果 recv 和 send 匹配,mpi 请求是否完成

c++ - 我可以告诉 Boost.MPI 哪个类版本与 Boost.Serialization 一起使用吗?

.net - 在 Windows Azure 上部署 MPI 应用程序

c - MPI_Waitsome 中发生错误

c - Eclipse "Nothing to Build for Project"生成错误

android - Kotlin Unresolved reference

build-error - Xcode 7.1.1 - fatal error : lipo: can't open input file

c++ - 在并行环境中使用 boost::log