我正在尝试在Ubuntu 14.04.3 LTS上安装Armadillo(6.500.5)http://arma.sourceforge.net/的最新版本。
我需要能够解决稀疏线性系统,因此,按照说明,我需要安装SuperLU版本4.3。我安装了SuperLU 4.3,但是在尝试构建Armadillo时收到以下错误
所以我将-fPIC标志添加到SuperLU makefile并重新编译了SuperLU,但随后得到了一个非常不同的错误
我不确定从这里要去哪里。似乎Armadillo希望以共享库格式找到SuperLU,而SuperLU将自身安装为静态库。软件包管理器中可用的Armdillo版本似乎已经过时,并且没有我需要的功能。
这是一些Makefile
SuperLU的顶层Makefile
############################################################################
#
# Program: SuperLU
#
# Module: Makefile
#
# Purpose: Top-level Makefile
#
# Creation date: October 2, 1995
#
# Modified: February 4, 1997 Version 1.0
# November 15, 1997 Version 1.1
# September 1, 1999 Version 2.0
# October 15, 2003 Version 3.0
# August 1, 2008 Version 3.1
#
############################################################################
include make.inc
all: install lib testing
lib: superlulib tmglib
clean: cleanlib cleantesting
install:
( cd INSTALL; $(MAKE) )
# ( cd INSTALL; cp lsame.c ../SRC/; \
# cp dlamch.c ../SRC/; cp slamch.c ../SRC/ )
blaslib:
( cd CBLAS; $(MAKE) )
superlulib:
( cd SRC; $(MAKE) )
tmglib:
( cd TESTING/MATGEN; $(MAKE) )
matlabmex:
( cd MATLAB; $(MAKE) )
testing:
( cd TESTING ; $(MAKE) )
doc:
doxygen Doxyfile
cleanlib:
( cd SRC; $(MAKE) clean )
( cd TESTING/MATGEN; $(MAKE) clean )
( cd CBLAS; $(MAKE) clean )
cleantesting:
( cd INSTALL; $(MAKE) clean )
( cd TESTING; $(MAKE) clean )
( cd MATLAB; $(MAKE) clean )
( cd EXAMPLE; $(MAKE) clean )
( cd FORTRAN; $(MAKE) clean )
SuperLU中的 make.inc
############################################################################
#
# Program: SuperLU
#
# Module: make.inc
#
# Purpose: Top-level Definitions
#
# Creation date: October 2, 1995
#
# Modified: February 4, 1997 Version 1.0
# November 15, 1997 Version 1.1
# September 1, 1999 Version 2.0
#
############################################################################
#
# The machine (platform) identifier to append to the library names
#
PLAT = _linux
#
# The name of the libraries to be created/linked to
#
SuperLUroot = /usr/lib/SuperLU_4.3
SUPERLULIB = $(SuperLUroot)/lib/libsuperlu_4.3.a
#BLASLIB = $(SuperLUroot)/lib/libblas.a
## ATLAS BLAS causes single-precision to fail
#BLASDEF = -DUSE_VENDOR_BLAS
#BLASLIB = /usr/lib/libopenblas.a
## This BLAS causes single-precision to fail the test in SuperLU
# BLASDEF = -DUSE_VENDOR_BLAS
BLASLIB = ../lib/blas$(PLAT).a
TMGLIB = libtmglib.a
LIBS = $(SUPERLULIB) $(BLASLIB)
#
# The archiver and the flag(s) to use when building archive (library)
# If your system has no ranlib, set RANLIB = echo.
#
ARCH = ar
ARCHFLAGS = cr
RANLIB = ranlib
CC = gcc
CFLAGS = -O3 -fPIC
NOOPTS =
FORTRAN = g77
FFLAGS = -O2 -fPIC
LOADER = $(CC)
LOADOPTS = -fPIC
#
# C preprocessor defs for compilation for the Fortran interface
# (-DNoChange, -DAdd_, -DAdd__, or -DUpCase)
#
CDEFS = -DAdd_
#
# The directory in which Matlab is installed
#
MATLAB = /usr/local/MATLAB/R2015b
SuperX中的 SRC / Makefile
# makefile for sparse supernodal LU, implemented in ANSI C
include ../make.inc
#######################################################################
# This is the makefile to create a library for SuperLU.
# The files are organized as follows:
#
# ALLAUX -- Auxiliary routines called from all precisions of SuperLU
# LAAUX -- LAPACK auxiliary routines called from all precisions
# SLASRC -- LAPACK single precision real routines
# DLASRC -- LAPACK double precision real routines
# CLASRC -- LAPACK single precision complex routines
# ZLASRC -- LAPACK double precision complex routines
# SCLAUX -- LAPACK Auxiliary routines called from both real and complex
# DZLAUX -- LAPACK Auxiliary routines called from both double precision
# and complex*16
# SLUSRC -- Single precision real SuperLU routines
# DLUSRC -- Double precision real SuperLU routines
# CLUSRC -- Single precision complex SuperLU routines
# ZLUSRC -- Double precision complex SuperLU routines
#
# The library can be set up to include routines for any combination
# of the four precisions. To create or add to the library, enter make
# followed by one or more of the precisions desired. Some examples:
# make single
# make single double
# make single double complex complex16
# Alternatively, the command
# make
# without any arguments creates a library of all four precisions.
# The library is called
# superlu.a
# and is created at the next higher directory level.
#
# To remove the object files after the library is created, enter
# make clean
#
#######################################################################
### LAPACK
LAAUX = lsame.o xerbla.o
SLASRC = slacon.o
DLASRC = dlacon.o
CLASRC = clacon.o scsum1.o icmax1.o
ZLASRC = zlacon.o dzsum1.o izmax1.o
SCLAUX = slamch.o
DZLAUX = dlamch.o
### SuperLU
ALLAUX = superlu_timer.o util.o memory.o get_perm_c.o mmd.o \
sp_coletree.o sp_preorder.o sp_ienv.o relax_snode.o \
heap_relax_snode.o colamd.o \
ilu_relax_snode.o ilu_heap_relax_snode.o mark_relax.o \
mc64ad.o qselect.o
SLUSRC = \
sgssv.o sgssvx.o \
ssp_blas2.o ssp_blas3.o sgscon.o \
slangs.o sgsequ.o slaqgs.o spivotgrowth.o \
sgsrfs.o sgstrf.o sgstrs.o scopy_to_ucol.o \
ssnode_dfs.o ssnode_bmod.o \
spanel_dfs.o spanel_bmod.o \
sreadhb.o sreadrb.o sreadtriple.o \
scolumn_dfs.o scolumn_bmod.o spivotL.o spruneL.o \
smemory.o sutil.o smyblas2.o \
sgsisx.o sgsitrf.o sldperm.o \
ilu_sdrop_row.o ilu_ssnode_dfs.o \
ilu_scolumn_dfs.o ilu_spanel_dfs.o ilu_scopy_to_ucol.o \
ilu_spivotL.o sdiagonal.o
DLUSRC = \
dgssv.o dgssvx.o \
dsp_blas2.o dsp_blas3.o dgscon.o \
dlangs.o dgsequ.o dlaqgs.o dpivotgrowth.o \
dgsrfs.o dgstrf.o dgstrs.o dcopy_to_ucol.o \
dsnode_dfs.o dsnode_bmod.o dpanel_dfs.o dpanel_bmod.o \
dreadhb.o dreadrb.o dreadtriple.o \
dcolumn_dfs.o dcolumn_bmod.o dpivotL.o dpruneL.o \
dmemory.o dutil.o dmyblas2.o \
dgsisx.o dgsitrf.o dldperm.o \
ilu_ddrop_row.o ilu_dsnode_dfs.o \
ilu_dcolumn_dfs.o ilu_dpanel_dfs.o ilu_dcopy_to_ucol.o \
ilu_dpivotL.o ddiagonal.o
## dgstrsL.o dgstrsU.o
CLUSRC = \
scomplex.o cgssv.o cgssvx.o csp_blas2.o csp_blas3.o cgscon.o \
clangs.o cgsequ.o claqgs.o cpivotgrowth.o \
cgsrfs.o cgstrf.o cgstrs.o ccopy_to_ucol.o \
csnode_dfs.o csnode_bmod.o \
cpanel_dfs.o cpanel_bmod.o \
creadhb.o creadrb.o creadtriple.o \
ccolumn_dfs.o ccolumn_bmod.o cpivotL.o cpruneL.o \
cmemory.o cutil.o cmyblas2.o \
cgsisx.o cgsitrf.o cldperm.o \
ilu_cdrop_row.o ilu_csnode_dfs.o \
ilu_ccolumn_dfs.o ilu_cpanel_dfs.o ilu_ccopy_to_ucol.o \
ilu_cpivotL.o cdiagonal.o
ZLUSRC = \
dcomplex.o zgssv.o zgssvx.o zsp_blas2.o zsp_blas3.o zgscon.o \
zlangs.o zgsequ.o zlaqgs.o zpivotgrowth.o \
zgsrfs.o zgstrf.o zgstrs.o zcopy_to_ucol.o \
zsnode_dfs.o zsnode_bmod.o \
zpanel_dfs.o zpanel_bmod.o \
zreadhb.o zreadrb.o zreadtriple.o \
zcolumn_dfs.o zcolumn_bmod.o zpivotL.o zpruneL.o \
zmemory.o zutil.o zmyblas2.o \
zgsisx.o zgsitrf.o zldperm.o \
ilu_zdrop_row.o ilu_zsnode_dfs.o \
ilu_zcolumn_dfs.o ilu_zpanel_dfs.o ilu_zcopy_to_ucol.o \
ilu_zpivotL.o zdiagonal.o
all: single double complex complex16
single: $(SLUSRC) $(ALLAUX) $(LAAUX) $(SLASRC) $(SCLAUX)
$(ARCH) $(ARCHFLAGS) $(SUPERLULIB) \
$(SLUSRC) $(ALLAUX) $(LAAUX) $(SLASRC) $(SCLAUX)
$(RANLIB) $(SUPERLULIB)
double: $(DLUSRC) $(ALLAUX) $(LAAUX) $(DLASRC) $(DZLAUX)
$(ARCH) $(ARCHFLAGS) $(SUPERLULIB) \
$(DLUSRC) $(ALLAUX) $(LAAUX) $(DLASRC) $(DZLAUX)
$(RANLIB) $(SUPERLULIB)
complex: $(CLUSRC) $(ALLAUX) $(LAAUX) $(CLASRC) $(SCLAUX)
$(ARCH) $(ARCHFLAGS) $(SUPERLULIB) \
$(CLUSRC) $(ALLAUX) $(LAAUX) $(CLASRC) $(SCLAUX)
$(RANLIB) $(SUPERLULIB)
complex16: $(ZLUSRC) $(ALLAUX) $(LAAUX) $(ZLASRC) $(DZLAUX)
$(ARCH) $(ARCHFLAGS) $(SUPERLULIB) \
$(ZLUSRC) $(ALLAUX) $(LAAUX) $(ZLASRC) $(DZLAUX)
$(RANLIB) $(SUPERLULIB)
##################################
# Do not optimize these routines #
##################################
slamch.o: slamch.c ; $(CC) -c $(NOOPTS) $(CDEFS) $<
dlamch.o: dlamch.c ; $(CC) -c $(NOOPTS) $(CDEFS) $<
superlu_timer.o: superlu_timer.c ; $(CC) -c $(NOOPTS) $<
##################################
.c.o:
$(CC) $(CFLAGS) $(CDEFS) $(BLASDEF) -c $< $(VERBOSE)
.f.o:
$(FORTRAN) $(FFLAGS) -c $<
clean:
rm -f *.o $(SUPERLULIB)
由CMake生成的Armadillo Makefile
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8
# Default target executed when no arguments are given to make.
default_target: all
.PHONY : default_target
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =
.SUFFIXES: .hpux_make_needs_suffix_list
# Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake
# The command to remove a file.
RM = /usr/bin/cmake -E remove -f
# Escaping for special characters.
EQUALS = =
# The program to use to edit the cache.
CMAKE_EDIT_COMMAND = /usr/bin/cmake-gui
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /home/daniel/Downloads/armadillo-6.500.5
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /home/daniel/Downloads/armadillo-6.500.5
#=============================================================================
# Targets provided globally by CMake.
# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
/usr/bin/cmake-gui -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : edit_cache
# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast
# Special rule for the target install
install: preinstall
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
/usr/bin/cmake -P cmake_install.cmake
.PHONY : install
# Special rule for the target install
install/fast: preinstall/fast
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
/usr/bin/cmake -P cmake_install.cmake
.PHONY : install/fast
# Special rule for the target install/local
install/local: preinstall
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..."
/usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
.PHONY : install/local
# Special rule for the target install/local
install/local/fast: install/local
.PHONY : install/local/fast
# Special rule for the target list_install_components
list_install_components:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\" \"dev\""
.PHONY : list_install_components
# Special rule for the target list_install_components
list_install_components/fast: list_install_components
.PHONY : list_install_components/fast
# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
/usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache
# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast
# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /home/daniel/Downloads/armadillo-6.500.5/CMakeFiles /home/daniel/Downloads/armadillo-6.500.5/CMakeFiles/progress.marks
$(MAKE) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start /home/daniel/Downloads/armadillo-6.500.5/CMakeFiles 0
.PHONY : all
# The main clean target
clean:
$(MAKE) -f CMakeFiles/Makefile2 clean
.PHONY : clean
# The main clean target
clean/fast: clean
.PHONY : clean/fast
# Prepare targets for installation.
preinstall: all
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall
# Prepare targets for installation.
preinstall/fast:
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast
# clear depends
depend:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend
#=============================================================================
# Target rules for targets named armadillo
# Build rule for target.
armadillo: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 armadillo
.PHONY : armadillo
# fast build rule for target.
armadillo/fast:
$(MAKE) -f CMakeFiles/armadillo.dir/build.make CMakeFiles/armadillo.dir/build
.PHONY : armadillo/fast
# Manual pre-install relink rule for target.
armadillo/preinstall:
$(MAKE) -f CMakeFiles/armadillo.dir/build.make CMakeFiles/armadillo.dir/preinstall
.PHONY : armadillo/preinstall
src/wrapper.o: src/wrapper.cpp.o
.PHONY : src/wrapper.o
# target to build an object file
src/wrapper.cpp.o:
$(MAKE) -f CMakeFiles/armadillo.dir/build.make CMakeFiles/armadillo.dir/src/wrapper.cpp.o
.PHONY : src/wrapper.cpp.o
src/wrapper.i: src/wrapper.cpp.i
.PHONY : src/wrapper.i
# target to preprocess a source file
src/wrapper.cpp.i:
$(MAKE) -f CMakeFiles/armadillo.dir/build.make CMakeFiles/armadillo.dir/src/wrapper.cpp.i
.PHONY : src/wrapper.cpp.i
src/wrapper.s: src/wrapper.cpp.s
.PHONY : src/wrapper.s
# target to generate assembly for a file
src/wrapper.cpp.s:
$(MAKE) -f CMakeFiles/armadillo.dir/build.make CMakeFiles/armadillo.dir/src/wrapper.cpp.s
.PHONY : src/wrapper.cpp.s
# Help Target
help:
@echo "The following are some of the valid targets for this Makefile:"
@echo "... all (the default if no target is provided)"
@echo "... clean"
@echo "... depend"
@echo "... armadillo"
@echo "... edit_cache"
@echo "... install"
@echo "... install/local"
@echo "... list_install_components"
@echo "... rebuild_cache"
@echo "... src/wrapper.o"
@echo "... src/wrapper.i"
@echo "... src/wrapper.s"
.PHONY : help
#=============================================================================
# Special targets to cleanup operation of make.
# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system
请让我知道我应该尝试什么。我在Linux上编译/链接库的经验不是很丰富,因此请尽可能提供详细信息。谢谢。
最佳答案
遇到相同的问题,即使您在 CFLAGS 中进行了设置,看起来 superlu_timer.c 并未使用 -fPIC 编译
由于某些原因,SuperLU背后的家伙不想优化该文件,因此他们在SRC文件夹的Makefile中为此单个文件设置了特定目标。
您可以在 SuperLU_4.3 / SRC / Makefile 中看到它:
##################################
# Do not optimize these routines #
##################################
slamch.o: slamch.c ; $(CC) -c $(NOOPTS) $(CDEFS) $<
dlamch.o: dlamch.c ; $(CC) -c $(NOOPTS) $(CDEFS) $<
superlu_timer.o: superlu_timer.c ; $(CC) -c $(NOOPTS) $<
##################################
解决方案是将 superlu_timer.o 行更改为包括 -fPIC :
superlu_timer.o: superlu_timer.c ; $(CC) -fPIC -c $(NOOPTS) $<
之后,只需执行
make clean
和make
再次生成库