如何在与 Cygwin 一起安装的 Windows 上执行 autoconf?

How do I execute autoconf on Windows as installed with Cygwin?

我正在尝试在 Windows 7 机器上构建一个 Linux 开发的 C++ 项目,我认为 Cygwin 将是 运行 最简单的方法之一必要的构建和编译脚本(在我的例子中,autoconf、make 和 g++)。我开始 运行 遇到问题,如果有人能告诉我我安装或做错了什么,我将不胜感激。

我可以使用 Chocolatey 命令安装 Cygwin

choco install -y cygwin

将 Cygwin 放在 C:\tools\cygwin 目录中。为了方便起见,我将 C:\tools\cygwin\bin 添加到我的 PATH.

接下来我使用

在安静模式下安装必要的包
C:\tools\cygwin\cygwin_setup.exe -q -P autoconf,make,gcc-g++

如果我输入命令 make,则该程序 运行s 会给我预期的错误消息。但是,如果我输入 autoconf,则会出现以下错误:

'autoconf' is not recognized as an internal or external command, operable program or batch file.

我认为原因是,与 Cygwin 的 bin 目录中的大多数脚本(例如 make)不同,这个脚本不是 .exe 文件。在文本编辑器中检查 autoconf 的内容时,我只看到一行乱码:

㰡祳汭湩㹫/usr/share/autotools/ac-wrapper.sh 

开头的字符看起来很可疑,但我的猜测是该脚本应该调用 C:\tools\cygwin\usr\share\autotools\ac-wrapper.sh 脚本。

所以我尝试 运行 该脚本作为可执行文件

C:\tools\cygwin\usr\share\autotools\ac-wrapper.sh

我第一次这样做时,它成功生成了 configure 可执行文件。我以为我已经解决了一切。但是在我清理了 autoconf 输出并再次尝试之后,什么也没有发生。即使我关闭 shell window 并重试,window 会短暂地出现一条消息并消失,但没有其他任何反应。

如果我 运行 带有

的包装脚本,我可以看到消息
sh C:\tools\cygwin\usr\share\autotools\ac-wrapper.sh

该消息原来是以下错误:

ac-wrapper: Unable to locate any usuable version of autoconf.
    I tried these versions: 2.69:2.5 2.68:2.5 9999:2.5 2.99:2.5 2.98:2.5 2.97:2.5 2.96:2.5 2.95:2.5 2.94:2.5 2.93:2.5 2.92:2.5 2.91:2.5 2.90:2.5 2.89:2.5 2.88:2.5 2.87:2.5 2.86:2.5 2.85:2.5 2.84:2.5 2.83:2.5 2.82:2.5 2.81:2.5 2.80:2.5 2.79:2.5 2.78:2.5 2.77:2.5 2.76:2.5 2.75:2.5 2.74:2.5 2.73:2.5 2.72:2.5 2.71:2.5 2.70:2.5 2.69:2.5 2.68:2.5 2.67:2.5 2.66:2.5 2.65:2.5 2.64:2.5 2.63:2.5 2.62:2.5 2.61:2.5 2.60:2.5 2.59:2.5  2.5x:2.5 2.13:2.1
C:\tools\cygwin\usr\share\autotools\ac-wrapper.sh: line 19: printf: missing unicode digit for \u
    With a base name of 'C: ools\cygwin\usr\shareutotoolsc-wrapper.sh'.

我假设最后一个与 Unicode 相关的错误是由于 autoconf 文件中的 CJK 字符造成的,但更令人担忧的是找到可用的 autoconf 版本的问题。这里发生了什么?我不能在安装了 Cygwin 的情况下从 Windows 命令行 运行 autoconf 吗?

大多数 cygwin 程序都是作为特殊的 link 实现的,只能工作 来自 cygwin shell(如 bash):

$ cd /usr/bin
$ ls -l autoconf
lrwxrwxrwx 1 Marco Kein 34 Oct 15  2018 autoconf -> /usr/share/autotools/ac-wrapper.sh

$ autoconf --version
autoconf (GNU Autoconf) 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+/Autoconf: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>, <http://gnu.org/licenses/exceptions.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David J. MacKenzie and Akim Demaille.

非cygwin程序的这些link是普通文件,不能使用

D:\cygwin32T\bin>dir /a:s autoconf.*
 Datenträger in Laufwerk D: ist DATA
 Volumeseriennummer: D603-FB6E

 Verzeichnis von D:\cygwin32T\bin

15.10.2018  08:53                82 autoconf
               1 Datei(en),             82 Bytes
               0 Verzeichnis(se), 662.133.735.424 Bytes frei

有效使用 cygwin 的最佳方法是 运行 提供的 Cygwin 终端(又名 Mintty)将启动 cygwin shell。 运行 来自 windows CMD 的 Cygwin 程序可能会导致意外结果。