Or is this only for cross-compiling from Mac OS to Linux?
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
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).
Currently only native Windows is available via MSVC.
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?
No the Visual C++ compiler is free to use.
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. 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
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.
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/)
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
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).
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