【问题标题】:Boost.MPI problemBoost.MPI 问题
【发布时间】:2010-12-05 01:02:16
【问题描述】:

我正在开发 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()'

如果有人能提供帮助,我将不胜感激。

【问题讨论】:

    标签: mpi build-error boost-mpi


    【解决方案1】:

    假设您使用的是 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
    

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

    【讨论】:

    • “正确的顺序,您需要将源文件作为第一个参数,而不是最后一个参数。” 为此 +1,只是花了很多时间安装和重新安装 boost因为这个细节
    【解决方案2】:

    不幸的是,我使用的是 boost 1.41,因此无法进行精确比较。但是,当我不包含 -lboost_mpi(新的库命名约定)时,我得到了完全相同的错误。所以,我会检查您的目录是否正确并包含您认为它们应该包含的内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-31
      • 2012-09-12
      • 2011-12-20
      • 2011-04-30
      • 2015-05-04
      • 2012-04-08
      • 2016-08-02
      • 2011-01-31
      相关资源
      最近更新 更多