尝试在 WINdows 上编译 gmp-6.2.1 时,使用“char 9:未终止的‘s’命令”失败

时间:2021-02-07 16:16:03

标签: sed makefile gnu-make gmp

所以我正在尝试编译 GNU Multiple Precision Arithmetic 库,以便在我的 Windows 10 PC 上运行 symengine。 我能够安装 MinGW、m4make 等先决条件并添加到 PATH。这些是我运行的以下命令

cd gmp-6.2.1
./configure --prefix=C:/GMP
make

现在当我运行 make 时,它​​会失败并显示给定的日志

/usr/bin/make  all-recursive
make[1]: Entering directory `/c/Users/Devesh/Downloads/gmp-6.2.1'
Making all in tests
make[2]: Entering directory `/c/Users/Devesh/Downloads/gmp-6.2.1/tests'
Making all in .
make[3]: Entering directory `/c/Users/Devesh/Downloads/gmp-6.2.1/tests'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/c/Users/Devesh/Downloads/gmp-6.2.1/tests'
Making all in devel
make[3]: Entering directory `/c/Users/Devesh/Downloads/gmp-6.2.1/tests/devel'
make[3]: Nothing to be done for `all'.
...
...
Making all in cxx
make[3]: Entering directory `/c/Users/Devesh/Downloads/gmp-6.2.1/tests/cxx'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/c/Users/Devesh/Downloads/gmp-6.2.1/tests/cxx'
make[2]: Leaving directory `/c/Users/Devesh/Downloads/gmp-6.2.1/tests'
Making all in mpn
make[2]: Entering directory `/c/Users/Devesh/Downloads/gmp-6.2.1/mpn'
/bin/sh ../libtool --mode=compile --tag=CC ../mpn/m4-ccas --m4="m4" gcc -c -DHAVE_CONFIG_H -I. -I..  -D__GMP_WITHIN_GMP -I.. -DOPERATION_`echo add_n | sed 's/_$//'`   -m32 -O2 -pedantic -fomit-frame-pointer -mtune=broadwell -march=broadwell  `test -f 'add_n.asm' || echo './'`add_n.asm
libtool: compile:  ../mpn/m4-ccas --m4=m4 gcc -c -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMP -I.. -DOPERATION_add_n -m32 -O2 -pedantic -fomit-frame-pointer -mtune=broadwell -march=broadwell add_n.asm -o add_n.o
/usr/bin/sed: -e expression #1, char 9: unterminated `s' command
No --m4 specified
make[2]: *** [add_n.lo] Error 1
make[2]: Leaving directory `/c/Users/Devesh/Downloads/gmp-6.2.1/mpn'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/c/Users/Devesh/Downloads/gmp-6.2.1'
make: *** [all] Error 2

似乎 sed 表达式失败了,但它应该如何不明显。第一个和第二个 libtool 命令标志在输出中不同 - -m4="m4" & -m4=m4 考虑到 make 规则是

.asm.lo:
    $(LIBTOOL) --mode=compile --tag=CC $(top_srcdir)/mpn/m4-ccas --m4="$(M4)" $(CCAS) $(COMPILE_FLAGS) `test -f '$<' || echo '$(srcdir)/'`$<

(注意我已经在 msys 文件夹中安装了 m4)。 我应该寻找任何指示来解决问题? 已附加 config.log

更新 带有 sed 命令的 gmp-6.2.1\mpn 中的相关 makefile 变量看起来很奇怪。似乎应该事先扩展它,因为 $* 是 makefile 中的自动变量。

AM_CPPFLAGS = -D__GMP_WITHIN_GMP -I$(top_srcdir) \
  -DOPERATION_`echo $* | sed 's/_$$//'`

其他子目录(如 mpf\mpq\)中的 Makefile 有这个 AM_CPPFLAGS = -D__GMP_WITHIN_GMP -I$(top_srcdir)

查看configure文件,sed字符串生成的地方好像有两个地方,主要是这里替换了$^

host_os=$*
IFS=$ac_save_IFS
case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
build_os=$*
IFS=$ac_save_IFS
case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac

1 个答案:

答案 0 :(得分:0)

我在 MINGW64 的 bash 上运行时出现错误。在 sh 上运行(从 MSYS 安装)成功。