我正在尝试重新编译已经具有 Windows 端口的应用程序(因此它应该可以工作)
当然,您仍然需要运行./configure
,因此您需要MSYS或MSYS2。
配置部分运行良好。现在,当我运行 make -n
(因此它显示执行了哪些规则)时,我得到:
$ make -n
if test ! -f config.h; then \
rm -f stamp-h1; \
make stamp-h1; \
else :; fi
! was unexpected
make: *** [config.h] Error 255
!出乎意料
是法语消息的近似翻译(因此可能略有不同),但让我想起了神秘的 Windows 批处理文件消息。所以我认为 make 使用 Windows native shell 运行其命令行(对于大多数简单命令来说这不是问题,但当它依赖于类似 bash 的 shell 时则不是问题),这一假设得到了证实使用 make Debug模式:
$ make -d
GNU Make 3.82
Built for i686-pc-mingw32
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
<I'll spare you that boring part then:>
Invoking recipe from Makefile:164 to update target `config.h'.
Creating temporary batch file C:\msys64\tmp\make11752-1.bat
Batch file contents:
@echo off
if test ! -f config.h; then rm -f stamp-h1; make stamp-h1; else :; fi
根据 make 文档,make
采用 SHELL
环境。考虑到变量。
SHELL
设置为 unix 样式路径,但我尝试使用 $ export SHELL="C:/msys64/usr/bin/bash.exe"更改它
以反射(reflect) native Windows 路径(make
可能无法识别 MSYS2),但无济于事)
那么如何告诉 make
使用 bash
shell 而不是 Windows shell 呢?
最佳答案
Built for i686-pc-mingw32
该行意味着您使用了错误版本的 GNU Make。您正在使用为 MinGW 运行时构建的版本,而不是为 MSYS2 运行时(Cygwin 的一个分支)构建的版本。
确保运行 pacman -S make
安装正确版本的 GNU Make,然后运行 which make
并确保它返回 /usr/bin/make
。新品牌应将自己标识为“Built for x86_64-pc-msys”之类的名称。
关于windows - 如何强制 make 在 Windows/MSYS2 上使用 bash 作为 shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45889953/