0

Note: This is not a duplicate, existing solution is obsolete (not working) as of Dec 2022

There is no package cygwin32-* (anymore?) in Cygwin64

https://www.cygwin.com/packages/summary/cygwin32-gcc-core.html
404 Not Found


I use Cygwin to build our library and app on the Windows platform. This works fine, so far. But only 64-Bit (x64) version is created until now. We need to create 32-Bit (i686) DLL too, because some developers still create 32-Bit (i686) programs, so they need our DLL as 32-Bit (i686) version!

How do I do this with Cygwin?

The gcc that comes with Cygwin64 (setup-x86_64.exe) only creates 64-Bit (x64) binaries, it appears. I tried switch -m32, but will fail with some obscure errors; looks like some libraries are wrong:

$ make CC="gcc -m32"
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/11//libgcc_s.dll.a when searching for -lgcc_s

I also tried installing 32-Bit Cygwin (setup-x86.exe), but setup only shows a weird error message: Cygwin is not supported on 32-Bit Windows

But I try to install Cygwin on a 64-Bit Windows machine (Windows 10 22H2, fully patched), so this error message makes no sense to me! How to install Cygwin 32-Bit version?

I also found various sources claiming that Cygwin64 can cross-compile to 32-Bit and that I need to install the cross-compiler packages cygwin32-* for that. But how do I do this? I tried to install those packages with the "setup-x86_64.exe" program, but can not seems to find them...

What am I missing?

Regards.


I tried to install 32-Bit Cygwin (setup-x86.exe), but it cannot install on my Windows 10 system.

Also I tried to cross-compile from Cygwin64 (x86_64) to 32-Bit (i686) platform, but it cannot find how to install the required cross-compiler packages (cygwin32-*).


Minimal example:

Command to create 64-Bit (x64) DLL in Cygwin64 shell works fine:

$ gcc -shared -o test.dll -Wl,--out-implib test.dll.a dll_test.c

But this command to create 32-Bit (i686) DLL cannot work:

$ gcc -m32 -shared -o test.dll -Wl,--out-implib test.dll.a dll_test.c

Error messages:

/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/11//libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/11/libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/11//libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/11/libgcc_s.dll.a when searching for -lgcc_s
[...]
collect2: error: ld returned 1 exit status

dll_test.c:

int test_function(void)
{
    return 42;
}
xepak62241
  • 31
  • 3
  • 2
    Does this answer your question? [compile 32bit code from cygwin64](https://stackoverflow.com/questions/30119573/compile-32bit-code-from-cygwin64) – stark Dec 06 '22 at 16:03
  • No. I already found that post. It says I am supposed to install "cygwin32-gcc" and "cygwin32-w32api-runtime" packages. But how do I do this? I cannot find them with the "setup-x86_64.exe" program! And the "setup-x86" doesn't work at all, as described above. I suspect that this solution is outdated and "cygwin32-gcc" is nowhere to be found in current Cygwin version – xepak62241 Dec 06 '22 at 16:07
  • 64-bit cygwin is all you need. Please add your Makefile to the question. You are most likely giving paths to the wrong compiler and libraries. – stark Dec 06 '22 at 16:12
  • I have added a minimal example to the original post. Does not even need a Makefile. – xepak62241 Dec 06 '22 at 16:30
  • What do you get from `which gcc`? – stark Dec 06 '22 at 16:45
  • `$ which gcc` returns `/usr/bin/gcc` – xepak62241 Dec 06 '22 at 16:47
  • Are there any cygwin packages whose name includes `multiarch`? Those might be what provide a 32-bit `libgcc_s.dll.a` which `gcc -m32` could find. – Peter Cordes Dec 06 '22 at 17:00
  • Sorry. Haven't used Cygwin in a while. msys2 proviveds mingw32 and 64-bit. Looks like you are right that there is only 64-bit under /lib/gcc. This page suggests loading the old version and has links: https://www.cygwin.com/install.html – stark Dec 06 '22 at 17:02
  • No, doesn't look like it. If I search "multi..." it only comes up with `qt5-multimedia`. Also, to the best of my knowledge, MSYS2 (MinGW) has **no** emulation of Unix APIs (`unistd.h`), which is in stark contrast to Cygwin, so MSYS2 (MinGW) is not usable for our task. – xepak62241 Dec 06 '22 at 17:03
  • **I found the solution:** Cygwin32 (setup-x86.exe) can only be installed by passing the option `--allow-unsupported-windows` to the setup program. Also, because the 32-Bit binaries are no longer available on "official" mirrors, we must use the Cygwin Time Machine mirror at `http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457` for the installation. This way we get a working 32-Bit `gcc` with all required libraries. Cygwin32 can be installed side-by-side with Cygwin64 without any problem. – xepak62241 Dec 09 '22 at 00:43

0 Answers0