-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Add mingw documentation #17219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Robert Schumacher (ras0219-msft)
merged 9 commits into
microsoft:master
from
dg0yt:mingw-docs
Apr 28, 2021
Merged
Add mingw documentation #17219
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a0a6c65
Add mingw documentation
dg0yt b136039
Minor edits
dg0yt ac80eb9
Fix typos
dg0yt 3798b80
Revise comments about tools
dg0yt 5d0e186
Make mingw-w64 explicit
dg0yt 0801d7c
Fix another typo
dg0yt cc4124d
How to avoid mixing different installations
dg0yt f39c647
Ban '/bin' from 'PATH', too
dg0yt 70b6c1f
Update mingw.md
ras0219-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| # Vcpkg and MinGW | ||
|
|
||
| **The latest version of this documentation is available on [GitHub](https://github.com/Microsoft/vcpkg/tree/master/docs/users/mingw.md).** | ||
|
|
||
| ## MinGW community triplets | ||
|
|
||
| vcpkg includes | ||
| [community triplets for MinGW](https://github.com/microsoft/vcpkg/tree/master/triplets/community) | ||
| for x64, x86, arm64 and arm. They don't depend on Visual Studio and | ||
| can be used natively on Windows as well as for cross-compiling on | ||
| other operating systems. There are two variants of each triplet, | ||
| selecting between static and dynamic linking: | ||
|
|
||
| - arm64-mingw-dynamic | ||
| - arm64-mingw-static | ||
| - arm-mingw-dynamic | ||
| - arm-mingw-static | ||
| - x64-mingw-dynamic | ||
| - x64-mingw-static | ||
| - x86-mingw-dynamic | ||
| - x86-mingw-static | ||
|
|
||
| These triplets are not tested by continuous integration, so many ports | ||
| do not build, and even existing ports may break on port updates. | ||
| Because of this, community involvement is paramount! | ||
|
|
||
| - [Discussions](https://github.com/microsoft/vcpkg/discussions?discussions_q=mingw) | ||
| - [Open issues](https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+mingw) | ||
| - [Open pull requests](https://github.com/microsoft/vcpkg/pulls?q=is%3Apr+is%3Aopen+mingw) | ||
|
|
||
| ## Using MinGW natively on Windows | ||
|
|
||
| With [MSYS2](https://www.msys2.org/), it is possible to easily create | ||
| a full environment for building ports with MinGW on a Windows PC. | ||
|
|
||
| Note that for building software for native windows environments, you | ||
| must use a mingw subsystem of MSYS2, and install some packages | ||
| (with a specific prefix) for this subsystem. | ||
|
|
||
| | architecture | vcpkg triplets | subsystem | package prefix | | ||
| |--------------|-------------------------------------|-----------|-------------------| | ||
| | x64 | x64-mingw-dynamic, x64-mingw-static | mingw64 | mingw-w64-x86_64- | | ||
| | x86 | x86-mingw-dynamic, x86-mingw-static | mingw32 | mingw-w64-i686- | | ||
|
|
||
| After the basic installation if MSYS2, you will need to install a few | ||
| additional packages for software development, e.g. for x64: | ||
|
|
||
| ```bash | ||
| pacman -S git mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja | ||
| ``` | ||
|
|
||
| The active subsystem is select by running the MSYS2 MinGW app, or | ||
| changed in a running terminal by | ||
|
|
||
| ```bash | ||
| source shell mingw64 # or mingw32 | ||
| ``` | ||
|
|
||
| The bootstrapping of vcpkg shall be done by running bootstrap_vcpkg.exe. | ||
| This will download the official vcpkg.exe. | ||
|
|
||
| ```bash | ||
| git clone https://github.com/microsoft/vcpkg.git | ||
| cd vcpkg | ||
| ./bootstrap-vcpkg.bat | ||
| ``` | ||
|
|
||
| For building packages, you need to tell vcpkg that you want to use the | ||
| MinGW triplet. This can be done in different ways. When Visual Studio | ||
| is not installed, you must also set the host triplet to mingw. This is | ||
| needed to resolve host dependencies. For convenience, you can use | ||
| environment variables to set both triplets: | ||
|
dg0yt marked this conversation as resolved.
|
||
|
|
||
| ```bash | ||
| export VCPKG_DEFAULT_TRIPLET=x64-mingw-dynamic | ||
| export VCPKG_DEFAULT_HOST_TRIPLET=x64-mingw-dynamic | ||
| ``` | ||
|
|
||
| Now you can test your setup: | ||
|
|
||
| ```bash | ||
| ./vcpkg install zlib | ||
| ``` | ||
|
|
||
| ## Using MinGW to build Windows programs on other systems | ||
|
|
||
| Many Linux distributions come with MinGW toolchains which allow to | ||
| cross-compile software on Linux to be run on Windows. You can use | ||
|
dg0yt marked this conversation as resolved.
Outdated
|
||
| such toolchains with vcpkg by setting the desired mingw triplet. | ||
|
|
||
| Note that the pre-installed cmake might be too old for vcpkg. | ||
|
|
||
| For bootstrapping, clone the github repository and run the shell script: | ||
|
|
||
| ```bash | ||
| git clone https://github.com/microsoft/vcpkg.git | ||
| cd vcpkg | ||
| ./bootstrap-vcpkg.sh | ||
| ./vcpkg install zlib:x64-mingw-dynamic | ||
| ``` | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.