使用 Accelerate Framework(LAPACK 和 BLAS)编译 Fortran 源代码
Compile Fortran source with Accelerate Framework (LAPACK and BLAS)
我希望编译使用 LAPACK
和 BLAS
函数的 Fortran
源代码。当我编译单个源代码文件时,例如
gfortran -g -framework accelerate test.f
有效。
但是,我有很多源代码文件想通过Makefile
编译。当我通过添加修改 Makefile
时:
LDFLAGS= -framework Accelerate
(Not sure it is the right way but that's how someone seemed to do it)
I get the error that the lapack function used inside is unrecognized.
谁能告诉我在 makefile 中要做什么修改?
这是我得到的错误:
gfortran -g test.o -o a.out
Undefined symbols for architecture x86_64:
"_sgesv_", referenced from:
_MAIN__ in test.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [a.out] Error 1
sgesv 是被调用的 lapack 子例程,应包含在 veclib/accelerate 框架中。
这是我的 Makefile 的副本:
#
#
#
#FFLAGS = -fast
#FFLAGS = gfortran
FC = gfortran
LFLAGS = gfortran -g
LINK = gfortran -g
LDFLAGS = -framework Accelerate
OBJECTS = test.o\
SOURCES = test.f\
a.out: $(OBJECTS)
$(LINK) $(OBJECTS) -o a.out
对于其他人:
这就是我做错的地方。最后一行应该改变:
$(LINK) $(对象) -o a.out $(LDFLAGS)
编译器告诉您它找不到 sgesv
,它是(在您的情况下)加速框架的一部分。从错误消息中,我看到 Makefile 生成的命令是
gfortran -g test.o -o a.out
缺少 linker 指令。
因此,在 Makefile 中,您在实际命令中缺少 link 标志:
a.out: $(OBJECTS)
$(LINK) $(OBJECTS) -o a.out $(LDFLAGS)
我希望编译使用 LAPACK
和 BLAS
函数的 Fortran
源代码。当我编译单个源代码文件时,例如
gfortran -g -framework accelerate test.f
有效。
但是,我有很多源代码文件想通过Makefile
编译。当我通过添加修改 Makefile
时:
LDFLAGS= -framework Accelerate
(Not sure it is the right way but that's how someone seemed to do it) I get the error that the lapack function used inside is unrecognized.
谁能告诉我在 makefile 中要做什么修改?
这是我得到的错误:
gfortran -g test.o -o a.out
Undefined symbols for architecture x86_64:
"_sgesv_", referenced from:
_MAIN__ in test.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [a.out] Error 1
sgesv 是被调用的 lapack 子例程,应包含在 veclib/accelerate 框架中。
这是我的 Makefile 的副本:
#
#
#
#FFLAGS = -fast
#FFLAGS = gfortran
FC = gfortran
LFLAGS = gfortran -g
LINK = gfortran -g
LDFLAGS = -framework Accelerate
OBJECTS = test.o\
SOURCES = test.f\
a.out: $(OBJECTS)
$(LINK) $(OBJECTS) -o a.out
对于其他人:
这就是我做错的地方。最后一行应该改变: $(LINK) $(对象) -o a.out $(LDFLAGS)
编译器告诉您它找不到 sgesv
,它是(在您的情况下)加速框架的一部分。从错误消息中,我看到 Makefile 生成的命令是
gfortran -g test.o -o a.out
缺少 linker 指令。
因此,在 Makefile 中,您在实际命令中缺少 link 标志:
a.out: $(OBJECTS)
$(LINK) $(OBJECTS) -o a.out $(LDFLAGS)