塞进裤子ヾ(≧O≦)〃嗷~

0%

linux下armadillo安装非root权限

linux系统,非root权限,即无sudo情况下,安装armadillo,blas,lapack,boost,cmake

armadillo要用到cmake,而且要先确保安装blas和lapack,而安装Lapack需要fortran编译器。
所以注意安装顺序

首先在个人根目录下新建temp文件夹存放文件

Cmake

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
官网下载
https://cmake.org/download/
下载后解压,然后进入目录执行:

tar zxvf c..

./bootstrap //可能需要chmod +x bootstrap 给权限
./configure --prefix=/home/LAB/sbaban
make -j8
make install
cmake --version//检查是否成功
若不成功,尝试以下操作
vi ~/.bashrc 最后一行加入
export PATH="$PATH:/home/LAB/sbaban"
source ~/.bashrc

Re:
没有sudo权限安装cmake
https://blog.csdn.net/opencv_857310866/article/details/81408641

安装openblas

cd temp #准备存放openblas的文件夹
git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS
make
make install PREFIX=/home/LAB/sbaban

安装fortran编译器

1
2
3
4
5
6
参考网页
https://blog.csdn.net/qq_43070386/article/details/83214690
由于没有root权限,注意修改了针对当前用户current user安装
最后一步改成 vim ~/.bashrc
. /home/LAB/sbaban/intel/bin/ifortvars.sh intel64
source ~/.bashrc intel64

PS:之前,先安装了它,导致openblas安装不上,如何卸载intel fortran编译器
https://software.intel.com/en-us/articles/uninstall-intel-compiler-for-linux-when-uninstallsh-is-missing-or-not-functioning
记得rm -r /home/LAB/sbaban下与intel有关的文件和文件夹

安装lapack

1
2
3
4
5
6
7
8
9
cd temp #准备存放lapack的文件夹
wget http://www.netlib.org/lapack/lapack-3.8.0.tar.gz
tar zxvf lapack-3.8.0.tar.gz
cd lapack-3.8.0
mkdir build
cd build
cmake -D CMAKE_INSTALL_PREFIX=/home/LAB/sbaban ..
make -j32
make install

安装armadillo

1
2
3
4
5
6
xz -d armadillo-9.300.2.tar.xz 
tar -xvf armadillo-9.300.2.tar
//参考readme文件,因为是非root,第3步改成
cmake -DCMAKE_INSTALL_PREFIX=/home/LAB/sbaban
make
make install

安装完后,armadillo头文件出现在/home/LAB/sbaban/include文件夹里,
要加入到环境变量

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
vim ~/.bashrc
export CPLUS_INCLUDE_PATH=/home/LAB/sbaban/include/
export LIBRARY_PATH="/home/LAB/sbaban/lib:$LIBRARY_PATH"
export LD_LIBRARY_PATH="/home/LAB/sbaban/lib:$LD_LIBRARY_PATH"
source ~/.bashrc

===测试armadillo
#include <iostream>
#include <armadillo>
using namespace arma;
int main()
{ mat A = randu<mat>(5, 5)*10;
A.print("A = \n");
}
编译运行
g++ del.cpp -o del -larmadillo

安装boost

1
2
3
4
https://www.cnblogs.com/oloroso/p/4632848.html
https://blog.csdn.net/this_capslock/article/details/47170313
注意第4步改成
./b2 --prefix=/home/LAB/sbaban install

—–以下内容写给自己看,读者不必在意
链接头文件
export CPLUS_INCLUDE_PATH=/home/LAB/include/
https://www.cnblogs.com/JiangLe/p/5855915.html

每次训练都要加入这一句
export CPLUS_INCLUDE_PATH=/home/LAB/sbaban/include/

if help:小手一抖点个广告 or 大手一挥资助一下