Subject: uninstalled executable does not work when compiling for 32-bit Cygwin

From: Bruno Haible <[email-masked]>
Date: Sun, 23 Oct 2016 00:28:24 +0200

Hi,

A 64-bit Cygwin environment [on Windows 10 in my case] (canonical platform
triplet: x86_64-pc-cygwin) has the following cross-compilation toolchains
(all installable through setup-x86_64.exe):

  * i686-pc-cygwin            (32-bit Cygwin)
  * i686-w64-mingw32          (32-bit mingw)
  * x86_64-w64-mingw32        (64-bit mingw)

and the executables built with the corresponding *-gcc compilers work out-of-
the-box (since they are Windows executables).

The problem
-----------

When compiling for 32-bit Cygwin a package that uses GNU libtool to
create a shared library and link with this shared library, uninstalled
executables (i.e. the executables in the build tree before "make install")
do not work. In order to make them work it is necessary to augment PATH:
add the particular .libs directory(ies) that contain the library(ies) that
the program is linked against.

I think this is a bug because
  - Other platforms do not have this problem (not even 32-bit mingw or
    64-bit mingw).
  - The .libs directory is an undocumented internal of GNU libtool.

How to reproduce
----------------

The package below is a GNU libiconv snapshot with GNU libtool 2.4.6.

$ wget http://www.haible.de/bruno/gnu/libiconv-20161022.tar.gz
$ tar xvfz libiconv-20161022.tar.gz
$ cd libiconv

$ PATH=/usr/local/cygwin32/bin:/usr/i686-pc-cygwin/sys-root/usr/bin:$PATH
$ ./configure --host=i686-pc-cygwin --prefix=/usr/local/cygwin32 \
            CC=i686-pc-cygwin-gcc \
            CXX=i686-pc-cygwin-g++ \
            CPPFLAGS="-I/usr/local/cygwin32/include -Wall" \
            LDFLAGS="-L/usr/local/cygwin32/lib"
...
$ make
...
$ src/iconv_no_i18n.exe --help
$ echo $?
127
$ PATH=lib/.libs:$PATH src/iconv_no_i18n.exe --help
Usage: iconv_no_i18n.exe ...
...
$ echo $?
0

For comparison, it works when compiling to 32-bit mingw
-------------------------------------------------------

$ PATH=/usr/local/mingw32/bin:$PATH
$ ./configure --host=i686-w64-mingw32 --prefix=/usr/local/mingw32 \
            CC=i686-w64-mingw32-gcc \
            CXX=i686-w64-mingw32-g++ \
            CPPFLAGS="-I/usr/local/mingw32/include -Wall" \
            LDFLAGS="-L/usr/local/mingw32/lib"
...
$ make
...
$ src/iconv_no_i18n.exe --help
Usage: iconv_no_i18n.exe ...
...
$ echo $?
0

Best regards,

                 Bruno
--
In memoriam Nunilo and Alodia <http://en.wikipedia.org/wiki/Nunilo_and_Alodia>