简体   繁体   English

如何编译lapack以便在安装八度音程时可以正确使用?

[英]how to compile lapack so that it can be used correctly during installation of octave?

I'm trying to install the latest octave 3.8.1 from source in a cluster running redhat+IBM LSF. 我正在尝试在运行redhat + IBM LSF的集群中从源安装最新的octave 3.8.1。 I don't have write access to anywhere else except my own home dir, that's why I have to install octave from source. 除了我自己的家庭目录之外,我没有其他任何地方的写访问权限,这就是我必须从源代码安装八度音程的原因。 The blas and lapack provided by the cluster does not work so I have to build them by myself. 集群提供的blas和lapack不起作用,所以我必须自己构建它们。 I have now finished compiling both blas and lapack and passed the ./configure , but when I run make, an error is reported as follows: 我现在已完成编译blas和lapack并传递./configure ,但是当我运行make时,报告错误如下:

在此输入图像描述

These are steps I used to build my own BLAS and LAPACK . 这些是我用来构建自己的BLASLAPACK The source of BLAS is in ~/src/BLAS while the source of LAPACK is in ~/src/lapack-3.5.0 and the source of octave 3.8.1 is in ~/src/octave-3.8.1 . BLAS的源代码在~/src/BLAS而LAPACK的源代码在~/src/lapack-3.5.0 ,而octave 3.8.1的源代码在~/src/octave-3.8.1 With only two module, 1) pcre/8.33 2) acml/5.3.1/gfortran64 , loaded, I compiled BLAS shared library using 只有两个模块, 1) pcre/8.33 2) acml/5.3.1/gfortran64 ,加载,我编译BLAS共享库使用

gfortran -shared -O2 *.f -o libblas.so -fPIC

and static library using 和静态库使用

gfortran -O2 -c *.f -fPIC
ar cr libblas.a *.o

Then I copy the shared library libblas.so to ~/src/octave-3.8.1. 然后我将共享库libblas.so复制到〜/ src / octave-3.8.1。 The contents of make.inc file in lapack's dir is: lapack的目录中make.inc文件的内容是:

####################################################################
#  LAPACK make include file.                                       #
#  LAPACK, Version 3.5.0                                           #
#  November 2013                                                   #
####################################################################
#
SHELL = /bin/sh
#  
#  Modify the FORTRAN and OPTS definitions to refer to the
#  compiler and desired compiler options for your machine.  NOOPT
#  refers to the compiler options desired when NO OPTIMIZATION is
#  selected.  Define LOADER and LOADOPTS to refer to the loader and 
#  desired load options for your machine.
#
FORTRAN  = gfortran 
OPTS     = -shared -O2 -fPIC
DRVOPTS  = $(OPTS)
NOOPT    = -O0 -frecursive
LOADER   = gfortran
LOADOPTS =
#
# Timer for the SECOND and DSECND routines
#
# Default : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME
#TIMER    = EXT_ETIME
# For RS6K : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME_
# TIMER    = EXT_ETIME_
# For gfortran compiler: SECOND and DSECND will use a call to the INTERNAL FUNCTION ETIME
TIMER    = INT_ETIME
# If your Fortran compiler does not provide etime (like Nag Fortran Compiler, etc...)
# SECOND and DSECND will use a call to the INTERNAL FUNCTION CPU_TIME
# TIMER    = INT_CPU_TIME
# If neither of this works...you can use the NONE value... In that case, SECOND and DSECND will always return 0
# TIMER     = NONE
#
#  Configuration LAPACKE: Native C interface to LAPACK
#  To generate LAPACKE library: type 'make lapackelib'
#  Configuration file: turned off (default)
#  Complex types: C99 (default)
#  Name pattern: mixed case (default)
#  (64-bit) Data model: LP64 (default)
#
# CC is the C compiler, normally invoked with options CFLAGS.
#
CC = gcc
CFLAGS = -O3
#
#  The archiver and the flag(s) to use when building archive (library)
#  If you system has no ranlib, set RANLIB = echo.
#
ARCH     = ar
ARCHFLAGS= cr
RANLIB   = ranlib
#
#  Location of the extended-precision BLAS (XBLAS) Fortran library
#  used for building and testing extended-precision routines.  The
#  relevant routines will be compiled and XBLAS will be linked only if
#  USEXBLAS is defined.
#
# USEXBLAS    = Yes
XBLASLIB     =
# XBLASLIB    = -lxblas
#
#  The location of the libraries to which you will link.  (The 
#  machine-specific, optimized BLAS library should be used whenever
#  possible.)
#
#BLASLIB      = ../../librefblas.a
BLASLIB      = ~/src/BLAS/libblas.a
LAPACKLIB    = liblapack.a
TMGLIB       = libtmglib.a
LAPACKELIB   = liblapacke.a

Then I type make to compile LAPACK. 然后我输入make来编译LAPACK。 After compilation, I copied the output liblapack.a to ~/src/octave-3.8.1. 编译后,我将输出liblapack.a复制到〜/ src / octave-3.8.1。

The ./configure command line is: ./configure命令行是:

./configure --prefix=$HOME/bin/octave --with-blas=./libblas.so --with-lapack=$HOME/src/octave-3.8.1/liblapack.a --disable-readline --enable-64

I can pass the ./configure. 我可以通过./configure。 Then I type make to try to build octave 3.8.1 and I got the above error. 然后我键入make以尝试构建八度音阶3.8.1并且我得到了上述错误。

From the make.inc file it can be seen that I have followed the suggestion of the compiler " recompile with -fPIC " and modified the make.inc accordingly. make.inc文件可以看出,我已经遵循了编译器“ recompile with -fPIC编译”的建议并相应地修改了make.inc。 I also add -shared switch in the OPTS variable. 我还在OPTS变量中添加了-shared开关。 In addition, I have tried using old LAPACK version but not working. 另外,我尝试使用旧的LAPACK版本,但没有工作。 I really have no idea why the error still comes out. 我真的不知道为什么错误仍然存​​在。 So I wonder if you could please tell me how to compile the LAPACK library so that it can be correctly used during installation of octave 3.8.1. 所以我想知道你是否可以告诉我如何编译LAPACK库,以便在安装octave 3.8.1时正确使用它。 The following two points may be worth considering. 以下两点可能值得考虑。 (1) should I compile lapack as a static library or a shared library? (1)我应该将lapack编译为静态库还是共享库? (2) should -fPIC switch be applied to lapack compilation or octave's make ? (2)应该将-fPIC开关应用于lapack编译还是octave的make If the latter, how to apply -fPIC to make? 如果是后者,如何申请-fPIC呢? You don't have to get restricted to the above two points since there may be other reasons for the error. 您不必限制上述两点,因为可能有其他原因导致错误。 Any advice to solve this problem is welcomed. 欢迎任何解决这个问题的建议。 If you need any other information please tell me. 如果您需要任何其他信息,请告诉我。 Thank you. 谢谢。

Just compiled the lapack shared lib on my boss's beast... Here's a link which almost did it right. 刚刚在我老板的野兽上编译了lapack共享库...这是一个几乎做得对的链接 I made some changes: 我做了一些改变:

(1) Adding -fPIC to (1)将-fPIC添加到

OPTS & NOOPT in make.inc

(2) Change the names in make.inc to .so (2)将make.inc中的名称更改为.so

BLASLIB = ../../libblas.so

LAPACKLIB = ../liblapack.so

(3) In ./SRC, change the Makefile from (3)在./SRC中,从中更改Makefile

../$(LAPACKLIB): $(ALLOBJ)
    $(ARCH) $(ARCHFLAGS) $@ $(ALLOBJ)
    $(RANLIB) $@

to

../$(LAPACKLIB): $(ALLOBJ)
    $(LOADER) $(LOADOPTS) -shared -Wl,-soname,liblapack.so -o $@ $(ALLOBJ) ../libblas.so

Cuz lapack is calling blas, if you miss the very last part, your liblapack.so will fail! Cuz lapack正在调用blas,如果你错过了最后一部分,你的liblapack.so将失败! You need to LINK liblapack.so against libblas.so ( libatlas.so is also OK). 你需要链接liblapack.so libblas.so(libatlas.so也行)。 You can use "ldd liblapack.so" to check its dependency. 您可以使用“ldd liblapack.so”来检查其依赖性。 If you see libblas.so in there, pretty much you did it right. 如果你在那里看到libblas.so,那么你做得很对。

(4) In ./BLAS/SRC, change the Makefile from (4)在./BLAS/SRC中,从中更改Makefile

$(BLASLIB): $(ALLOBJ)
$(ARCH) $(ARCHFLAGS) $@ $(ALLOBJ)
$(RANLIB) $@

to

$(BLASLIB): $(ALLOBJ)
$(LOADER) $(LOADOPTS) -z muldefs -shared -Wl,-soname,libblas.so -o $@ $(ALLOBJ)

(5) I don't need libtmg.so so that I didn't change it... Run (5)我不需要libtmg.so所以我没有改变它...运行

make blaslib 

Then 然后

make lapacklib

You will have both of them compiled. 您将编译它们。 I check the liblapack.so with building a numpy on it and Python ctypes.cdll loading. 我检查了liblapack.so,并在其上构建了一个numpy并加载了Python ctypes.cdll。 All work for me to solve eigenvalues and eigenvectors... So it should be fine... 所有工作对我来说都是解决特征值和特征向量...所以应该没问题......

(6) YOU MAY NEED TO SET UP LD_LIBRARY_PATH to where you keep your library files. (6)您可能需要将LD_LIBRARY_PATH设置为保存库文件的位置。 google it... If not set by admin, then google it ...如果没有由admin设置,那么

export LD_LIBRARY_PATH=path-to-lib

If already set, then 如果已经设置,那么

export LD_LIBRARY_PATH=path-to-lib:$LD_LIBRARY_PATH

to overwrite your default libs. 覆盖默认的库。

So that you won't have ld linking errors. 这样你就不会有ld链接错误。 Good luck!! 祝好运!!

In lapack-3.7.0, there are redundant lines in the SRC/Makefile. 在lapack-3.7.0中,SRC / Makefile中有冗余行。 Simply deleting them will solve your error. 只需删除它们即可解决您的错误。

I would suggest using OpenBLAS. 我建议使用OpenBLAS。

> git clone https://github.com/xianyi/OpenBLAS.git
> make
> make make --PREFIX=INSTALL_DIR install

move the librabries from OpenBLAS to /usr/lib64 将librabries从OpenBLAS移到/ usr / lib64

> cp /path/to/OpenBLAS/lib/* /usr/lib64/

then go to the octave installation path and run 然后转到八度安装路径并运行

> "your specific flags" ./configure "your specific arguments" --with-blas="-lopenblas"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM