Search code examples
windowscygwinautoconf

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


I'm trying to build a Linux-developed C++ project on a Windows 7 machine, and I figured that Cygwin would be one of the easiest ways to run the necessary build and compilation scripts (in my case, autoconf, make, and g++). I'm starting to run into problems, and I'd appreciate it if someone could showing me if I'm installing or doing something incorrectly.

I can install Cygwin with Chocolatey with the command

choco install -y cygwin

which places Cygwin in the C:\tools\cygwin directory. For convenience, I add C:\tools\cygwin\bin to my PATH.

Next I install the necessary packages in quiet mode with

C:\tools\cygwin\cygwin_setup.exe -q -P autoconf,make,gcc-g++

If I enter the command make, then that program runs and gives me the expected error message. But if I enter autoconf, then I get the following error:

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

I assume the reason is because, unlike most of the scripts in Cygwin's bin directory (such as make), this one is not a .exe file. When check the contents of autoconf in a text editor, I see just a single garbled line:

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

The initial characters seem pretty suspect, but my guess is that the script is supposed to call the C:\tools\cygwin\usr\share\autotools\ac-wrapper.sh script.

So I tried to run that script as an executable with

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

The first time I did this, it successfully generated the configure executable. I thought I had everything solved. But after I cleaned up the autoconf outputs and tried again, nothing happened. Even if I close the shell window and try again, a window briefly appears with a message and disappears, but nothing else happens.

I can see the message if I run the wrapper script with

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

The message turns out to be the following error:

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'.

I assume that last Unicode-related error is due to the CJK characters in the autoconf file, but the issue with finding a usable version of autoconf is more concerning. What's going on here? Shouldn't I be able to run autoconf from the Windows command-line with Cygwin installed?


Solution

  • Most of the cygwin programs are implemented as special link, that works only from a cygwin shell (like 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.
    

    These links for not-cygwin programs are normal files and they can not use them

    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
    

    The best way to use cygwin effectively is to run the provided Cygwin Terminal (aka Mintty) that will start a cygwin shell. Running Cygwin programs from windows CMD could cause unexpected results.