[英]how to compile lapack so that it can be used correctly during installation of octave?
我正在嘗試在運行redhat + IBM LSF的集群中從源安裝最新的octave 3.8.1。 除了我自己的家庭目錄之外,我沒有其他任何地方的寫訪問權限,這就是我必須從源代碼安裝八度音程的原因。 集群提供的blas和lapack不起作用,所以我必須自己構建它們。 我現在已完成編譯blas和lapack並傳遞./configure
,但是當我運行make時,報告錯誤如下:
這些是我用來構建自己的BLAS
和LAPACK
。 BLAS的源代碼在~/src/BLAS
而LAPACK的源代碼在~/src/lapack-3.5.0
,而octave 3.8.1的源代碼在~/src/octave-3.8.1
。 只有兩個模塊, 1) pcre/8.33 2) acml/5.3.1/gfortran64
,加載,我編譯BLAS共享庫使用
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。 我還在OPTS
變量中添加了-shared
開關。 另外,我嘗試使用舊的LAPACK版本,但沒有工作。 我真的不知道為什么錯誤仍然存在。 所以我想知道你是否可以告訴我如何編譯LAPACK
庫,以便在安裝octave 3.8.1時正確使用它。 以下兩點可能值得考慮。 (1)我應該將lapack編譯為靜態庫還是共享庫? (2)應該將-fPIC
開關應用於lapack編譯還是octave的make
? 如果是后者,如何申請-fPIC呢? 您不必限制上述兩點,因為可能有其他原因導致錯誤。 歡迎任何解決這個問題的建議。 如果您需要任何其他信息,請告訴我。 謝謝。
剛剛在我老板的野獸上編譯了lapack共享庫...這是一個幾乎做得對的鏈接 。 我做了一些改變:
(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中有冗余行。 只需刪除它們即可解決您的錯誤。
我建議使用OpenBLAS。
> git clone https://github.com/xianyi/OpenBLAS.git
> make
> make make --PREFIX=INSTALL_DIR install
將librabries從OpenBLAS移到/ usr / lib64
> cp /path/to/OpenBLAS/lib/* /usr/lib64/
然后轉到八度安裝路徑並運行
> "your specific flags" ./configure "your specific arguments" --with-blas="-lopenblas"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.