MPICH 3.2.1 & Boost 1.68.0编译安装

!!!参考了好多博客自己尝试了好多天程序终于跑通了特此总结,其他版本编译安装步骤应该一样,仅供参考

0 准备工作

安装前输入下面代码确认是否安装gcc,g++,gfotran,python 2.x(python 2.2 以上的版本都可以)

$ sudo apt-get install gcc
$ sudo apt-get install g++
$ sudo apt-get install gfortran
$ sudo apt-get install python

1 编译安装MPICH

# 下载安装包
$ wget http://www.mpich.org/static/downloads/3.2.1/mpich-3.2.1.tar.gz
# 解压
$ tar zxvf mpich-3.2.1.tar.gz
# 进入文件夹
$ cd mpich-3.2.1
# 编译 安装
$ mkdir /home/liu/mpich
$ ./configure --prefix=/home/liu/mpich( = 后面是文件安装路径)
$ make
$ make install
# 环境变量配置
$ sudo gedit ~/.bashrc
# 在文件末尾补上下面这句话
export PATH=/home/liu/mpich/bin:$PATH
# 保存退出后,再更新配置文件使其生效
$ source ~/.bashrc
# 检验是否安装成功
$ cd /home/liu/mpich-3.2.1/examples
$ mpirun -np 2 ./cpi

在这里插入图片描述
参考博客:
https://blog.csdn.net/sinat_30967935/article/details/82988659
http://blog.chinaunix.net/uid-29530577-id-4141020.html

2 编译 安装 Boost

卸载之前的安装

$ sudo apt --purge remove libboost-dev
$ sudo apt --purge remove libboost-all-dev
$ sudo apt --purge autoremove libboost-all-dev
$ sudo rm -rf /usr/lib/libboost_*
$ sudo rm -rf /usr/include/boost

下载安装依赖文件

$ apt-get install mpi-default-dev  #安装mpi库 
$ apt-get install libicu-dev     #支持正则表达式的UNICODE字符集 
$ apt-get install python-dev     #需要python的话 
$ apt-get install libbz2-dev 
# 下载
$ wget https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.gz
# 解压
$ tar -xzvf boost_1_68_0.tar.gz
$ cd boost_1_68_0
$ ./bootstrap.sh
# 重点!!!!修改 project-config.jam 文件,在第22行后添加一句: using mpi ; 如下图所示,注意添加位置,以及 mpi 和 ; 之间需要一个空格。
$ sudo gedit project-config.jam

在这里插入图片描述

# 执行
$  ./b2
$  sudo ./b2  install
# 添加boost lib路径到默认搜索路径
$  sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/boost.conf'
# 更新搜索路径
$ sudo ldconfig

测试

// test.cpp
#include <iostream>
#include <boost/array.hpp>
#include <boost/version.hpp>

using namespace std;
int main(){
  boost::array<int, 4> arr = {{1,2,3,4}};
  cout << "hi" << arr[0] << endl;
  cout << "BOOST VERSION: " << BOOST_LIB_VERSION << endl;
  return 0;
}
$ g++ test.cpp -o test
$ ./test

再在自己的程序上测试就可以啦

我的项目测试

$ cd /home/liu/MPIK-Means/test
$ mpic++ -o mpitest mpitest.cpp -L/usr/local/lib -lboost_mpi -lboost_serialization 
$ mpirun -np 3 ./mpitest

若结果如下,有三个Process则证明安装成功!

Process 1: a msg from master
 
Process 2: a msg from master
 
Process 2:
Process 1:
Process 0: zero one two
Process 0: zero one two
Process 1: zero one two
Process 2: zero one two

参考博客:
https://blog.csdn.net/huigougou/article/details/84351578
https://blog.csdn.net/hzrandd/article/details/22989187

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在CentOS上安装MPICH需要进行以下步骤: 1. 首先,安装编译器。可以使用yum命令进行安装: ``` sudo yum install make sudo yum install gcc sudo yum install gcc-c ``` 2. 下载MPICH安装包并解压。可以从官网上下载指定版本的安装包,例如mpich-3.2.1。使用wget命令下载: ``` wget http://www.mpich.org/static/downloads/3.2.1/mpich-3.2.1.tar.gz ``` 3. 在准备安装MPICH之前,需要创建一个安装目录。可以选择在当前目录下创建,也可以选择创建一个新的目录。在这里,我们以在/home/[USERNAME]/mpich-install目录下安装为例。使用以下命令创建目录: ``` cd /home/[USERNAME] mkdir mpich-install ``` 4. 接下来,进入解压后的MPICH安装包目录,并执行以下命令进行配置和安装: ``` cd mpich-3.2.1 ./configure --prefix=/home/[USERNAME]/mpich-install make sudo make install ``` 5. 安装完成后,可以根据MPICH的官方文档进行配置和使用。可以查阅官方文档和入门安装文档获取更多信息。 请注意,上述步骤中的[USERNAME]需要替换为你的用户名。另外,确保你有足够的权限进行安装和配置。 希望以上信息对你有所帮助!&lt;span class=&quot;em&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;em&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;em&quot;&gt;3&lt;/span&gt; #### 引用[.reference_title] - *1* [CentOS 7下安装MPICH3.2过程详解](https://blog.csdn.net/qq_33892998/article/details/78687529)[target=&quot;_blank&quot; data-report-click={&quot;spm&quot;:&quot;1018.2226.3001.9630&quot;,&quot;extra&quot;:{&quot;utm_source&quot;:&quot;vip_chatgpt_common_search_pc_result&quot;,&quot;utm_medium&quot;:&quot;distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2&quot;}}] [.reference_item style=&quot;max-width: 50%&quot;] - *2* *3* [【无标题】CentOS安装Mpich](https://blog.csdn.net/sinat_22510827/article/details/123813861)[target=&quot;_blank&quot; data-report-click={&quot;spm&quot;:&quot;1018.2226.3001.9630&quot;,&quot;extra&quot;:{&quot;utm_source&quot;:&quot;vip_chatgpt_common_search_pc_result&quot;,&quot;utm_medium&quot;:&quot;distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2&quot;}}] [.reference_item style=&quot;max-width: 50%&quot;] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值