Boost.MPI问题
我在做HPC。在HPC上安装了旧版本的Boost,而Boost库没有Boost.MPI。我请求管理员在HPC上安装它。但是他们要求我把它安装在我的主目录上。所以我在我的主目录上安装了boost和boost.mpi。Boost库似乎工作正常。但是当我尝试用下面的命令运行下面的代码时,我得到了错误 测试代码:Boost.MPI问题,mpi,build-error,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
#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;
}
我犯了以下错误:
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()'
如果你们能提供帮助,我将不胜感激。不幸的是,我使用的是boost 1.41,因此无法进行精确的比较。然而,当我没有将-lboost\u mpi包含在新的库命名约定中时,我得到了完全相同的错误。因此,我会检查您的目录是否正确,是否包含您认为应该包含的内容。假设您使用的是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
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