windows - 如何在安装了 Cygwin 的 Windows 上执行 autoconf?
问题描述
我正在尝试在 Windows 7 机器上构建 Linux 开发的 C++ 项目,我认为 Cygwin 将是运行必要的构建和编译脚本(在我的情况下是 autoconf、make 和 g++)的最简单方法之一. 我开始遇到问题,如果有人能告诉我我安装或做错了什么,我将不胜感激。
我可以使用以下命令安装 Cygwin 和 Chocolatey
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++
如果我输入 command make
,那么该程序将运行并给我预期的错误消息。但是,如果我输入autoconf
,则会收到以下错误:
'autoconf' is not recognized as an internal or external command, operable program or batch file.
我认为原因是因为与 Cygwinbin
目录中的大多数脚本(例如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 窗口并重试,窗口也会短暂出现一条消息并消失,但没有其他任何反应。
如果我运行包装脚本,我可以看到该消息
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 程序都是作为特殊链接实现的,它只能在 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程序的链接是普通文件,不能使用
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 程序可能会导致意外结果。
推荐阅读
- c# - 如何像 Microsoft Groove 音乐一样为 GridViewItem 图像设置动画
- java - 有没有办法从 Neo4j 图数据库自动生成 java 类
- python-3.x - 如何使用多索引数据框绘制两级 x-ticklabels
- java - 使用java将文件从父目录移动到子目录
- testing - Testcafe:轮询测试
- mysql - 同一列表/表中的 Linq 子查询
- python - Mac OS 上 PyQT5 应用程序中 textedit.clear() 的奇怪行为
- shell - 特定列号与特定字符串的模式匹配。没有分隔符或分隔符
- c# - AWS Lambda Selenium WebDriver - 加载 ibglib-2.0.so 时出错
- angular - 预期 = 1,接收 = 0 - 为什么我的函数没有在 Angular 测试中调用?