【问题标题】:SPheno-4.0.5 make command not running (MacOS)SPheno-4.0.5 make 命令未运行 (MacOS)
【发布时间】:2021-11-29 00:16:33
【问题描述】:

在我的工作中,我使用了一个名为 SPheno 的基于 Fortran 的程序。安装了 SPheno-4.0.4 后,我尝试安装新版本的 SPheno-4.0.5,但是,当在 Makefile 中选择 F90 = gfortran 时,就像我在工作的 SPheno-4.0.4 版本上所做的那样,它返回给我以下错误:

cd src ; /Library/Developer/CommandLineTools/usr/bin/make F90=gfortran version=400.00
gfortran -c -O -J../include -I../include  -DGENERATIONMIXING  -DONLYDOUBLE Control.F90
ar  ../lib/libSPheno.a Control.o
/Library/Developer/CommandLineTools/usr/bin/ar: illegal option -- .
usage:  ar -d [-TLsv] archive file ...
    ar -m [-TLsv] archive file ...
    ar -m [-abiTLsv] position archive file ...
    ar -p [-TLsv] archive [file ...]
    ar -q [-cTLsv] archive file ...
    ar -r [-cuTLsv] archive file ...
    ar -r [-abciuTLsv] position archive file ...
    ar -t [-TLsv] archive [file ...]
    ar -x [-ouTLsv] archive [file ...]
make[1]: *** [../lib/libSPheno.a(Control.o)] Error 1
make: *** [bin/SPheno] Error 2

这个错误甚至意味着什么,我需要改变什么?我什至尝试从 SPheno-4.0.4 复制/粘贴 Makefile,只是为了检查。

如果有问题,当运行命令 gfortran -v 时,它会返回我:

Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/11.2.0/libexec/gcc/x86_64-apple-darwin19/11.2.0/lto-wrapper
Target: x86_64-apple-darwin19
Configured with: ../configure --prefix=/usr/local/Cellar/gcc/11.2.0 --libdir=/usr/local/Cellar/gcc/11.2.0/lib/gcc/11 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran,d --program-suffix=-11 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-zstd=/usr/local/opt/zstd --with-pkgversion='Homebrew GCC 11.2.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --enable-libphobos --build=x86_64-apple-darwin19 --with-system-zlib --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Homebrew GCC 11.2.0)

使用的 Makefile 如下:

# please put here your preferred F95/F2003 compiler
# the options in src/Makefile have been put for the
# cases NAG's nagfor, gfortran, g95, Lahey's lf95 and Intels ifort
# Please uncomment the corresponding line
# F90 = nagfor
 F90 = gfortran
# F90 = g95
# F90 = lf95
# F90 = ifort
Model = src
version = 400.00
bin/SPheno:
    cd ${Model} ; ${MAKE} F90=${F90} version=${version}
clean:
    rm -f *.o *~ */*.o */*~
cleanall:
    rm -f bin/SPheno lib/*.a *.o *~ */*.o */*~ include/*
.PHONY: bin/SPheno clean cleanall

【问题讨论】:

  • 从您上面给出的内容看来,问题与 gfortran 无关,而是与 ar 相关,您需要提供一个额外的选项来指定您想要做什么 - 我猜是您需要-r。我不能说你是怎么做到的,你没有提供足够的信息。
  • 非常感谢您的回复!我可以提供什么信息来使问题更清楚?我不太了解返回的错误,所以我不知道确切地显示什么。我也尝试使用命令make -r,但它不起作用。

标签: macos makefile fortran gnu-make gfortran


【解决方案1】:

输出意味着 make 调用了这个命令:

ar  ../lib/libSPheno.a Control.o

它运行ar(存档)程序,显然想将Control.o 对象放入../lib/libSPheno.a 存档中。但是,该命令行是不正确的,因为在ar 之后应该有一个选项告诉它要执行什么操作。这个输出:

/Library/Developer/CommandLineTools/usr/bin/ar: illegal option -- .
usage:  ar -d [-TLsv] archive file ...
  ...

ar 程序打印,告诉您您的调用无效。

然后这一行:

make[1]: *** [../lib/libSPheno.a(Control.o)] Error 1

make 告诉您它调用 (ar) 来构建目标 ../lib/libSPheno.a(Control.o) 的命令失败,错误代码为 1。

您需要在 makefile 中的某处找到告诉 make 运行 ar 程序的规则。我们不能告诉你它在哪里;不幸的是,您的 make 版本太旧了(Apple 因发布过时和有缺陷的 GNU 实用程序版本而臭名昭著):较新的版本会为您提供 makefile 中失败的规则的行号。

该规则很可能会引用变量 $(AR) 或者 $(ARFLAGS) 或其他东西。

【讨论】:

  • 非常感谢您以如此易于理解的方式分解此消息!与此同时,我还尝试运行make CC=/usr/local/bin/gcc-11以便它使用 brew 的安装(如其他一些帖子中所述),但它返回了相同的错误消息。打开 Makefile 时,我看不到任何与 ar 相关的选项。我将在编辑中发布 Makefile。
  • 那是因为您正在查看错误的文件。在您的 makefile 中,您可以看到它实际上在子目录中运行 make:cd ${Model} ; ${MAKE} F90=${F90} version=${version}${Model} 变量是src,这意味着您需要查看src/Makefile。我怀疑此文件太大,无法在此处发布,因此请仔细查看并尝试找到相应的规则。
  • 非常感谢!修补该文件夹上的 Makefile 就可以了!请问你怎么知道${Model} 变量是src
  • 因为你显示的makefile中的Model = src
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-14
  • 2018-11-05
  • 2017-03-15
  • 2010-12-24
  • 2019-04-18
相关资源
最近更新 更多