# Cross-compiling to Windows : Do the following instructions also apply for Windows (with MingW)

**URL:** <https://forum.crystal-lang.org/t/cross-compiling-to-windows-do-the-following-instructions-also-apply-for-windows-with-mingw/5327>\
**Category:** Help & Support\
**Created:** [February 4, 2023, 9:15pm UTC](https://forum.crystal-lang.org/t/cross-compiling-to-windows-do-the-following-instructions-also-apply-for-windows-with-mingw/5327 "2023-02-04T21:15:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![serge-hulne](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/serge-hulne/32/1211_2.png) [@serge-hulne](https://forum.crystal-lang.org/u/serge-hulne)\
**Post date:** [February 4, 2023, 9:15pm UTC](https://forum.crystal-lang.org/t/cross-compiling-to-windows-do-the-following-instructions-also-apply-for-windows-with-mingw/5327/1 "2023-02-04T21:15:18Z")

</div>

Or is this only for cross-compiling from Mac OS to Linux?

```auto
Using these two, we can compile a program in a Mac that will run on that Linux like this:

crystal build your_program.cr --cross-compile --target "x86_64-unknown-linux-gnu"
This will generate a .o (Object file) and will print a line with a command to execute on the system we are trying to cross-compile to. For example:

cc your_program.o -o your_program -lpcre -lrt -lm -lgc -lunwind

```

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [February 4, 2023, 9:57pm UTC](https://forum.crystal-lang.org/t/cross-compiling-to-windows-do-the-following-instructions-also-apply-for-windows-with-mingw/5327/2 "2023-02-04T21:57:02Z")

</div>

The host platform doesn’t matter. As long as the compiler runs, it can cross-compile to any supported target platform.

MingW is not supported though (ref [Build with Mingw-w64 · Issue #6170 · crystal-lang/crystal · GitHub](https://github.com/crystal-lang/crystal/issues/6170)).  
Currently only native Windows is available via MSVC.

---

<div class="post-metadata">

**Author:** ![rmbishop](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/rmbishop/32/1949_2.png) [@rmbishop](https://forum.crystal-lang.org/u/rmbishop)\
**Post date:** [April 5, 2023, 11:53pm UTC](https://forum.crystal-lang.org/t/cross-compiling-to-windows-do-the-following-instructions-also-apply-for-windows-with-mingw/5327/3 "2023-04-05T23:53:25Z")

</div>

Does the reliance on Visual Studio mean that Crystal (on Windows) cannot be used by a corporation unless the proper Visual Studio license is purchased?

---

<div class="post-metadata">

**Author:** ![npn](https://avatars.discourse-cdn.com/v4/letter/n/e68b1a/32.png) [@npn](https://forum.crystal-lang.org/u/npn)\
**Post date:** [April 6, 2023, 2:29am UTC](https://forum.crystal-lang.org/t/cross-compiling-to-windows-do-the-following-instructions-also-apply-for-windows-with-mingw/5327/4 "2023-04-06T02:29:44Z")

</div>

No the Visual C++ compiler is free to use.

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [April 6, 2023, 10:11am UTC](https://forum.crystal-lang.org/t/cross-compiling-to-windows-do-the-following-instructions-also-apply-for-windows-with-mingw/5327/5 "2023-04-06T10:11:14Z")

</div>

Crystal does not require _Visual Studio_.

It needs Microsoft’s compiler tool chain which is available as part of the [_Buildtools für Visual Studio_](https://visualstudio.microsoft.com/de/visual-cpp-build-tools/). It is licensed independently and free of charge for many use cases, especially regarding Open Source software.  
Please consult the license terms regarding your specific situation: [License Terms | Microsoft Diagnostic Build Tools for Visual Studio 2022 - Visual Studio](https://visualstudio.microsoft.com/license-terms/vs2022-ga-diagnosticbuildtools/)

---

<div class="post-metadata">

**Author:** ![rmbishop](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/rmbishop/32/1949_2.png) [@rmbishop](https://forum.crystal-lang.org/u/rmbishop)\
**Post date:** [April 6, 2023, 11:51am UTC](https://forum.crystal-lang.org/t/cross-compiling-to-windows-do-the-following-instructions-also-apply-for-windows-with-mingw/5327/6 "2023-04-06T11:51:04Z")

</div>

In the license terms you linked the way I interpret 1.a and 1.b is that one needs a Visual Studio license unless developing open source software.

---

<div class="post-metadata">

**Author:** ![rmbishop](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/rmbishop/32/1949_2.png) [@rmbishop](https://forum.crystal-lang.org/u/rmbishop)\
**Post date:** [April 6, 2023, 10:21pm UTC](https://forum.crystal-lang.org/t/cross-compiling-to-windows-do-the-following-instructions-also-apply-for-windows-with-mingw/5327/7 "2023-04-06T22:21:15Z")

</div>

Following up for clarity:  
1)If you are developing proprietary code, you will need a visual studio license **src** : [https://devblogs.microsoft.com/cppblog/updates-to-visual-studio-build-tools-license-for-c-and-cpp-open-source-projects/](https://devblogs.microsoft.com/cppblog/updates-to-visual-studio-build-tools-license-for-c-and-cpp-open-source-projects/))

2)For an “enterprise”, the visual studio license cannot be “community” unless you are developing the following:  
(i) open source; (ii) Visual Studio extensions; (iii) device drivers for the Windows operating system; (iv) SQL Server development; and, (v) education purposes as permitted

src: [https://visualstudio.microsoft.com/license-terms/vs2022-ga-community/](https://visualstudio.microsoft.com/license-terms/vs2022-ga-community/)

---

<div class="post-metadata">

**Author:** ![HertzDevil](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/hertzdevil/32/1023_2.png) [@HertzDevil](https://forum.crystal-lang.org/u/HertzDevil)\
**Post date:** [April 7, 2023, 10:07pm UTC](https://forum.crystal-lang.org/t/cross-compiling-to-windows-do-the-following-instructions-also-apply-for-windows-with-mingw/5327/8 "2023-04-07T22:07:48Z")

</div>

One minor note: currently Crystal only supports static linking on Windows MSVC, which means LGPL components in the standard library may not be compatible with your project’s license (`Big*` numbers, string encoding).

---

<div class="post-metadata">

**Author:** ![HertzDevil](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/hertzdevil/32/1023_2.png) [@HertzDevil](https://forum.crystal-lang.org/u/HertzDevil)\
**Post date:** [May 22, 2023, 9:08am UTC](https://forum.crystal-lang.org/t/cross-compiling-to-windows-do-the-following-instructions-also-apply-for-windows-with-mingw/5327/9 "2023-05-22T09:08:48Z")

</div>

Another note: while dynamic linking will be supported soon, `vcruntime*.dll` is not redistributable by its own and the users have to install the Visual C++ Redistributable package themselves. However this is likely to change in the future as [Microsoft is in the process of open-sourcing vcruntime and vcstartup](https://github.com/microsoft/STL/issues/3628)
