ubuntu 安装OpenBLAS

安装的步骤如下:

(1)git clone git://github.com/xianyi/OpenBLAS

(2)cd OpenBLAS

(3)sudo make FC=gfortran (如果没有安装gfortran,执行sudo apt-get install gfortran)

也可以用这个指令,就把安装目录改为下面的目录了:/usr/local/Openblas/

sudo make --PREFIX=/usr/local/Openblas/ install /*安装*/

(4) sudo make install (将OpenBLAS安装到/opt下)

结果如下:

make -j 8 -f Makefile.install install
make[1]: Entering directory '/home/lbg/下载/OpenBLAS'
Generating openblas_config.h in /opt/OpenBLAS/include
Generating f77blas.h in /opt/OpenBLAS/include
Generating cblas.h in /opt/OpenBLAS/include
Copying LAPACKE header files to /opt/OpenBLAS/include
Copying the static library to /opt/OpenBLAS/lib
Copying the shared library to /opt/OpenBLAS/lib
Generating openblas.pc in /opt/OpenBLAS/lib/pkgconfig
Generating OpenBLASConfig.cmake in /opt/OpenBLAS/lib/cmake/openblas
Generating OpenBLASConfigVersion.cmake in /opt/OpenBLAS/lib/cmake/openblas
Install OK!
make[1]: Leaving directory '/home/lbg/下载/OpenBLAS'

编译好的文件夹大小40M

(5)执行以下命令完成安装

ln -s /opt/OpenBLAS/lib/libopenblas.so /usr/lib/libblas.so.3

ln -s /opt/OpenBLAS/lib/liblapack.so.3 /usr/lib/liblapack.so.3
再次运行程序,则不会发生此类错误

make时报错:

Check what version of gcc,g++,and gfortran you have:/usr/bin/ld: cannot find -lgfortran
 g++ --version gcc --version gfortran --version

结果gfortran也有,在目录/usr/lib/x86_64-linux-gnu/里面,

sudo ln -s /usr/lib/x86_64-linux-gnu/libgfortran.so.3 /usr/lib/libgfortran.so

就可以了


使用编译例子:

gcc testOpenBlas.c -I /opt/OpenBLAS/include/ -L/opt/OpenBLAS/lib -lopenblas

相关文章

文章浏览阅读2.3k次,点赞4次,收藏22次。最近安装了CARLA预...
文章浏览阅读6.3k次,点赞5次,收藏15次。在清华镜像中下载U...
文章浏览阅读5k次。linux环境, python3.7.问题描述: 安装...
文章浏览阅读4.2k次,点赞4次,收藏17次。要安装这个 standa...
文章浏览阅读894次,点赞51次,收藏31次。在安卓使用vscode主...