Antonin Décimo
Antonin Décimo

Reputation: 527

Cross-compilation targeting Cygwin with Linux host

Is it possible to cross-compile a program targeting a Cygwin environment from a Linux/Unix host? I'm mostly trying to avoid using a Windows (virtual) machine for building a collection of programs.

From the website:

Cygwin is not:

  • a way to run native Linux apps on Windows. You must rebuild your application from source if you want it to run on Windows.

mingw-w64 is not enough, I need a full POSIX platform. I'm also wondering if it's possible to target MSYS2.

Perhaps I do not understand correctly, and one doesn't need to compile in Cygwin, but only mingw-w64 is necessary.

Thanks!

Upvotes: 1

Views: 342

Answers (2)

ivop
ivop

Reputation: 11

Here's a collection of scripts that builds a Linux hosted cross-compiler that targets x86_64-pc-cygwin.

https://github.com/ivop/cygcross

Edit: Sorry, I'm new here. Full disclosure: I'm the author of said scripts. With it, you can build binutils and gcc on Linux to target Cygwin64, meaning you can compile binaries that will run on Windows with the cygwin1.dll. After that, you can install binary tarballs from the Cygwin project at will in the same installation prefix and they will be picked up by the compiler. It's advised to use static linking so only the cygwin1.dll file has to be distributed along with your program. Hope this helps.

Upvotes: 1

matzeri
matzeri

Reputation: 8486

It is possible to compile for Cygwin from Linux.
The cygwin1.dll itself is built in such way.

Packages/libraries are available at:

https://copr.fedorainfracloud.org/coprs/yselkowitz/cygwin/

Of course only a minimal set of tools/libraries is available

Upvotes: 2

Related Questions