A collection of scripts for "installing" the Microsoft compiler (cl.exe) on GNU/Linux.
The installation process is not completely automated, since the Visual Studio Installer does not seem to work under wine.
Therefore:
-
Use a real Windows machine for installing Visual Studio
-
Copy in a separate folder in the GNU/Linux environment all installed files
If you wan’t to create an archive, disable compression, otherwise the process will take a lot of time, and there won’t be any benefit, as the archive won’t be significantly smaller.
7zip is probably the fastest tool:
7z a vs.zip -tzip -mx=0 'C:/Program Files (x86)/Microsoft SDKs' 'C:/Program Files (x86)/Microsoft Visual Studio' 'C:/Program Files (x86)/MSBuild' 'C:/Program Files (x86)/Windows Kits'
If cygwin (and zip) are avaiable:
cd '/cygdrive/c/Program Files (x86)' && zip -0 -r ~/vs.zip 'Microsoft SDKs' 'Microsoft Visual Studio' 'MSBuild' 'Windows Kits'
From powershell (at least version 5, uses a lot of memory!):
Compress-Archive -CompressionLevel NoCompression -Path 'C:/Program Files (x86)/Microsoft SDKs', 'C:/Program Files (x86)/Microsoft Visual Studio', 'C:/Program Files (x86)/MSBuild', 'C:/Program Files (x86)/Windows Kits' -DestinationPath vs.zip
On a machine with wine:
-
execute
create-wine-prefix
(use--help
for checking available options), for creating a wine prefix for the compiler environment, and for generating wrapper scripts. -
execute
test.sh
to verify that compiling, linking and execution of the compiled programs works
Now have fun, you should be able to execute wine-cl
, wine-link
, wine-rc
, wine-mt
, …
They support all flags of the native tool, and some in addition like --help
and --version
.
Notice that the status of those scripts is still alpha-quality, no seriuous projects where compiler with it. This is a list of things to do in order to ensure some stability:
-
Try to add some tests with external libraries.
-
Add a test that needs
mt.exe
. -
Apparently
/Zi
and/FS
together are not supported in wine, this should get investigate further. For now/Zi
is ignored. -
Add test for other build systems apart from CMake.
-
Enhance
test.sh
, it should build every target in a separate subfolder. -
Install CMake in the wine prefix, and test it too.
The goal of this project is to provide an easy and automated way to add the windows compiler on GNU/Linux systems as if it would be another native program.
This is especially useful when testing or playing with small code snippets to ensure compatibility between different compilers.
Of course it would be nice if it would work as any other native compiler, that’s the reason test.sh
also executes CMake for testing.
Since paths are translated from Unix to Windows every time, and not just when invoking CMake the first time, it will not be as performant.
A better solution for building big projects could be to install CMake in wine too, and execute it from cmd.exe
, then all paths would be translated only the first time.