我正在尝试在运行redhat + IBM LSF的集群中从源安装最新的octave 3.8.1。除了我自己的家庭目录之外,我没有其他任何地方的写访问权限,这就是我必须从源代码安装八度音程的原因。集群提供的blas和lapack不起作用,所以我必须自己构建它们。我现在已完成编译blas和lapack并传递./configure
,但是当我运行make时,报告错误如下:
这些是我用来构建自己的BLAS
和LAPACK
的步骤。 BLAS的来源位于~/src/BLAS
,而LAPACK的来源位于~/src/lapack-3.5.0
,而八度音阶3.8.1的来源位于~/src/octave-3.8.1
。
只加载了两个模块1) pcre/8.33 2) acml/5.3.1/gfortran64
,我使用
gfortran -shared -O2 *.f -o libblas.so -fPIC
和静态库使用
gfortran -O2 -c *.f -fPIC
ar cr libblas.a *.o
然后我将共享库libblas.so
复制到〜/ src / octave-3.8.1。 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
然后我输入make来编译LAPACK。编译之后,我将输出liblapack.a
复制到〜/ src / octave-3.8.1。
./configure
命令行是:
./configure --prefix=$HOME/bin/octave --with-blas=./libblas.so --with-lapack=$HOME/src/octave-3.8.1/liblapack.a --disable-readline --enable-64
我可以通过./configure。然后我输入make
以尝试构建八度音阶3.8.1并且我得到了上述错误。
从make.inc
文件可以看出我已经遵循编译器“recompile with -fPIC
”的建议并相应地修改了make.inc。我还在-shared
变量中添加OPTS
开关。另外,我尝试使用旧的LAPACK版本,但没有工作。我真的不知道为什么错误仍然存在。所以我想知道你是否可以告诉我如何编译LAPACK
库,以便在安装octave 3.8.1时正确使用它。以下两点可能值得考虑。 (1)我应该将lapack编译为静态库还是共享库? (2)应该-fPIC
切换应用于lapack编译还是八度音阶make
?如果是后者,如何申请-fPIC呢?您不必限制上述两点,因为可能有其他原因导致错误。欢迎任何解决这个问题的建议。如果您需要任何其他信息,请告诉我。谢谢。
答案 0 :(得分:6)
刚刚在我老板的野兽上编译了lapack共享库...这里a link几乎做得对。 我做了一些改变:
(1)将-fPIC添加到
OPTS & NOOPT in make.inc
(2)将make.inc中的名称更改为.so
BLASLIB = ../../libblas.so
LAPACKLIB = ../liblapack.so
(3)在./SRC中,从
更改Makefile../$(LAPACKLIB): $(ALLOBJ)
$(ARCH) $(ARCHFLAGS) $@ $(ALLOBJ)
$(RANLIB) $@
到
../$(LAPACKLIB): $(ALLOBJ)
$(LOADER) $(LOADOPTS) -shared -Wl,-soname,liblapack.so -o $@ $(ALLOBJ) ../libblas.so
Cuz lapack正在调用blas,如果你错过了最后一部分,你的liblapack.so会失败!你需要链接liblapack.so libblas.so(libatlas.so也行)。你可以使用" ldd liblapack.so"检查它的依赖性。如果你在那里看到libblas.so,那么你做得非常好。
(4)在./BLAS/SRC中,从
更改Makefile$(BLASLIB): $(ALLOBJ)
$(ARCH) $(ARCHFLAGS) $@ $(ALLOBJ)
$(RANLIB) $@
到
$(BLASLIB): $(ALLOBJ)
$(LOADER) $(LOADOPTS) -z muldefs -shared -Wl,-soname,libblas.so -o $@ $(ALLOBJ)
(5)我不需要libtmg.so所以我没有改变它... 运行
make blaslib
然后
make lapacklib
您将同时编译它们。我检查了liblapack.so,并在其上构建了一个numpy并加载了Python ctypes.cdll。所有工作对我来说都是解决特征值和特征向量......所以应该没问题......
(6)您可能需要将LD_LIBRARY_PATH设置为保存库文件的位置。 google it ...如果没有由admin设置,那么
export LD_LIBRARY_PATH=path-to-lib
如果已设置,则
export LD_LIBRARY_PATH=path-to-lib:$LD_LIBRARY_PATH
覆盖默认的库。
这样你就不会有ld链接错误。祝你好运!!
在lapack-3.7.0中,SRC / Makefile中有冗余行。只需删除它们即可解决您的错误。
答案 1 :(得分:0)
我建议使用OpenBLAS。
> git clone https://github.com/xianyi/OpenBLAS.git
> make
> make make --PREFIX=INSTALL_DIR install
将库文件从OpenBLAS移至/ usr / lib64
> cp /path/to/OpenBLAS/lib/* /usr/lib64/
然后转到八度安装路径并运行
> "your specific flags" ./configure "your specific arguments" --with-blas="-lopenblas"