boost mpi示例编译

时间:2018-07-05 02:17:10

标签: boost compilation mpi

我将使用boost_mpi,但是在编译测试程序时发生了以下问题。

问题

/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_mpi.so: undefined reference to `ompi_mpi_info_null'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_mpi.so: undefined reference to `ompi_request_null'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_mpi.so: undefined reference to `ompi_mpi_packed'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_mpi.so: undefined reference to `ompi_mpi_comm_null'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_mpi.so: undefined reference to `ompi_mpi_errors_return'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_mpi.so: undefined reference to `MPI::Comm::Comm()'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_mpi.so: undefined reference to `ompi_op_set_cxx_callback'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_mpi.so: undefined reference to `ompi_mpi_cxx_op_intercept'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_mpi.so: undefined reference to `ompi_mpi_datatype_null'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_mpi.so: undefined reference to `ompi_mpi_comm_world'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_mpi.so: undefined reference to `ompi_mpi_unsigned_long'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_mpi.so: undefined reference to `ompi_mpi_group_empty'
collect2: error: ld returned 1 exit status
make[2]: *** [Test] Error 1
make[1]: *** [CMakeFiles/Test.dir/all] Error 2
make: *** [all] Error 2

其他信息

我的libboost是由apt-get install libboost-dev-all安装的,版本号是1.54。 我的GCC版本是4.8.4,MPICH版本是3.2。

这是我的测试代码:

#include <boost/mpi.hpp>
#include <iostream>

int main(int argc, char *argv[])
{
    boost::mpi::environment env{argc, argv};
    boost::mpi::communicator world;
    std::cout << world.rank() << ", " << world.size() << '\n';
}

1 个答案:

答案 0 :(得分:0)

您使用的是哪个Ubuntu版本?上面看起来有些奇怪。看起来像是一个非常老的系统?

apt -y install libboost-mpi-dev libmpich-dev openmpi-bin

应该就可以了。 libboost-mpi-dev不属于boost-all。然后构建您的代码:

mpicxx -std=c++11 -o test test.cpp -lboost_mpi

您在test.cpp中进行编码的位置。测试:

mpiexec -np 4 ./test