{"id":13592132,"url":"https://github.com/paleozogt/MSVCDocker","last_synced_at":"2025-04-08T23:30:52.887Z","repository":{"id":48812350,"uuid":"146942213","full_name":"paleozogt/MSVCDocker","owner":"paleozogt","description":"MSVC via Wine in Docker","archived":false,"fork":false,"pushed_at":"2021-07-10T15:52:17.000Z","size":104,"stargazers_count":121,"open_issues_count":12,"forks_count":21,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-08-02T16:44:08.189Z","etag":null,"topics":["ci","docker","msvc","vagrant","virtualbox","visual-studio","windows","wine"],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paleozogt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-31T21:06:18.000Z","updated_at":"2024-07-01T04:13:01.000Z","dependencies_parsed_at":"2022-09-23T21:51:04.020Z","dependency_job_id":null,"html_url":"https://github.com/paleozogt/MSVCDocker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paleozogt%2FMSVCDocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paleozogt%2FMSVCDocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paleozogt%2FMSVCDocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paleozogt%2FMSVCDocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paleozogt","download_url":"https://codeload.github.com/paleozogt/MSVCDocker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223346543,"owners_count":17130459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","docker","msvc","vagrant","virtualbox","visual-studio","windows","wine"],"created_at":"2024-08-01T16:01:06.074Z","updated_at":"2024-11-06T13:30:20.989Z","avatar_url":"https://github.com/paleozogt.png","language":"PowerShell","funding_links":[],"categories":["PowerShell"],"sub_categories":[],"readme":"[![Build Status](https://dev.azure.com/paleozogt/MSVCDocker/_apis/build/status/paleozogt.MSVCDocker?branchName=master)](https://dev.azure.com/paleozogt/MSVCDocker/_build/latest?definitionId=3\u0026branchName=master)\n\n# Microsoft Visual C via Wine in Docker\n\nCI with [MSVC](https://visualstudio.microsoft.com/vs/community/) is unnecessarily difficult. Can't we just use [Docker](https://www.docker.com/get-started)?\n\nIt turns out we can-- by running MSVC in [Wine](https://www.winehq.org/).  Lots of folks have tried to do this over the years [[1](README.md#references)], but the setup is involved and fiddly.  But scripting complicated setups is what Docker was made for!\n\nThe big blocker to getting MSVC in Wine is that even though the software itself works under Wine, the installers *don't*.  We dodge that problem by using [Vagrant](https://www.vagrantup.com/downloads.html) to drive the MSVC installer in a real Windows OS within [VirtualBox](https://www.virtualbox.org/wiki/Downloads), export a snapshot of the installation, and then [Docker](https://www.docker.com/get-started) copies the snapshot into Wine.\n\n## Requirements\n\n * [Docker](https://www.docker.com/get-started)\n    * If on Linux, allow Docker to be used [without sudo](https://docs.docker.com/engine/installation/linux/linux-postinstall/)\n * [VirtualBox](https://www.virtualbox.org/wiki/Downloads)\n * [Vagrant](https://www.vagrantup.com/downloads.html) v2.2.10+\n    * [Vagrant Reload Plugin](https://github.com/aidanns/vagrant-reload)\n\n## Building an Image\n\nTo create an `msvc:15` Docker image:\n\n```\nmake clean\nmake msvc15\n```\n\nMSVC 9, 10, 11, 12, 14, 15, and 16 are supported.\n\nNote: The snapshot step can take quite some time, as the MSVC installers are notoriously gigantic and slow.\n\n## Usage\n\nLet's simplify our Docker command:\n```\nfunction vcwine() { docker run -v$HOME:/host/$HOME -w/host/$PWD -u $(id -u):$(id -g) -eMSVCARCH=$MSVCARCH --rm -t -i msvc:15 \"$@\"; }\n```\n\nThe Docker images are setup to run (nearly) everything through Wine.  So for example, we can do DOS things like `dir`:\n\n```\n✗ vcwine cmd /c dir\nVolume in drive Z has no label.\nVolume Serial Number is 0000-0000\n\nDirectory of Z:\\host\\Users\\paleozogt\\Development\\test\\MSVCDocker\n\n 8/31/2018   9:08 PM  \u003cDIR\u003e         .\n 8/31/2018   9:21 PM  \u003cDIR\u003e         ..\n 8/31/2018   8:55 PM  \u003cDIR\u003e         build\n 8/31/2018   9:07 PM         3,421  Dockerfile\n 8/31/2018   9:07 PM  \u003cDIR\u003e         dockertools\n 8/31/2018   9:07 PM           464  Makefile\n 8/31/2018   9:08 PM            45  README.md\n 8/31/2018   9:07 PM  \u003cDIR\u003e         test\n 8/31/2018   9:07 PM         2,654  Vagrantfile\n 8/31/2018   9:07 PM  \u003cDIR\u003e         vagranttools\n       4 files                    6,584 bytes\n       6 directories     97,359,118,336 bytes free\n```\n\n### MSVC's cl\n\nCompiling a Hello World:\n```\n✗ vcwine cl test/helloworld.cpp \nMicrosoft (R) C/C++ Optimizing Compiler Version 19.15.26726 for x64\nCopyright (C) Microsoft Corporation.  All rights reserved.\n\nhelloworld.cpp\nC:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.15.26726\\include\\xlocale(319): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc\nMicrosoft (R) Incremental Linker Version 14.15.26726.0\nCopyright (C) Microsoft Corporation.  All rights reserved.\n\n/out:helloworld.exe \nhelloworld.obj \n\n\n✗ vcwine helloworld.exe\nhello world from win x86_64 msvc v1915\n```\n\nEven though its 2018, maybe we want to build for 32-bit:\n```\n✗ MSVCARCH=32 vcwine cl test/helloworld.cpp\nMicrosoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86\nCopyright (C) Microsoft Corporation.  All rights reserved.\n\nhelloworld.cpp\nC:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\INCLUDE\\xlocale(337) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc\nMicrosoft (R) Incremental Linker Version 12.00.31101.0\nCopyright (C) Microsoft Corporation.  All rights reserved.\n\n/out:helloworld.exe\nhelloworld.obj\n\n\n✗ vcwine helloworld.exe\nhello world from win x86 msvc v1915\n```\n\n### LLVM's clang-cl\n\n[Clang](https://clang.llvm.org/) can cross-compile MSVC-compatible binaries with [clang-cl](http://blog.llvm.org/2018/03/clang-is-now-used-to-build-chrome-for.html).\nA linux version is included (ie, it doesn't use Wine), but it still needs the MSVC installation for headers/libs, and Wine is still useful for running\nthe resulting binary.\n\nCompiling a Hello World:\n```\n✗ vcwine clang-cl test/helloworld.cpp \n\n\n✗ vcwine helloworld.exe\nhello world from win x86_64 clang v7\n```\n\nEven though its 2018, maybe we want to build for 32-bit:\n```\n✗ MSVCARCH=32 vcwine clang-cl test/helloworld.cpp\n\n\n✗ vcwine helloworld.exe\nhello world from win x86 clang v7\n```\n\n## Examples\n\nFor more examples, including the use of CMake and high-level language bindings, see the [examples](examples) subfolder.\n\n## Known Issues\n\n* MSBuild doesn't work, so we can't do things like\n\n  ```\n  vcwine cmake ../../test -G \"Visual Studio 15 2017 Win64\"\n  vcwine msbuild\n  ```\n\n  If you're using CMake, use the \"NMake Makefiles\", \"NMake Makefiles JOM\", or \"Ninja\" generators.\n\n* When using LLVM's clang-cl, paths that begin with `/U` (such as `/Users/`) will cause [strange errors](https://reviews.llvm.org/D29198):\n\n  ```\n  clang-7: warning: '/Users/paleozogt/Development/test/MSVCDocker/build/test/CMakeFiles/CMakeTmp/testCCompiler.c' treated as the '/U' option [-Wslash-u-filename]\n  clang-7: note: Use '--' to treat subsequent arguments as filenames\n  clang-7: error: no input files\n  ```\n\n  It appears that `/Users/...` is getting mistaken for a cl flag `/U`.\n\n## References\n * https://hackernoon.com/a-c-hello-world-and-a-glass-of-wine-oh-my-263434c0b8ad\n * https://dekken.github.io/2015/12/29/MSVC2015-on-Debian-with-Wine-and-Maiken.html\n * http://kegel.com/wine/cl-howto.html\n * https://sites.google.com/site/mookmoz2/linux-msvc-cross-compile\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaleozogt%2FMSVCDocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaleozogt%2FMSVCDocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaleozogt%2FMSVCDocker/lists"}