Boost.MPI问题

时间:2009-10-08 15:25:05

标签: mpi build-error boost-mpi

我正在研究HPC。在HPC上安装了旧版本的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()'

如果你们中的任何人能提供帮助,我将非常感激。

2 个答案:

答案 0 :(得分:3)

假设您使用的是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 :(得分:2)

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

相关问题