|
| 1 | +.. _examples_dev_flow_tool_requires_mingw: |
| 2 | + |
| 3 | +Using a MinGW as tool_requires to build with gcc in Windows |
| 4 | +----------------------------------------------------------- |
| 5 | + |
| 6 | +If we had MinGW installed in our environment, we could define a profile like: |
| 7 | + |
| 8 | +.. code-block:: |
| 9 | +
|
| 10 | + [settings] |
| 11 | + os=Windows |
| 12 | + compiler=gcc |
| 13 | + compiler.version=12 |
| 14 | + compiler.libcxx=libstdc++11 |
| 15 | + compiler.threads=posix |
| 16 | + compiler.exception=sjlj |
| 17 | + arch=x86_64 |
| 18 | + build_type=Release |
| 19 | +
|
| 20 | + [buildenv] |
| 21 | + PATH+=(path)C:/path/to/mingw/bin |
| 22 | + # other environment we might need like |
| 23 | + CXX=C:/path/to/mingw/bin/g++ |
| 24 | + # etc |
| 25 | +
|
| 26 | + [conf] |
| 27 | + # some configuration like 'tools.build:compiler_executables' might be needed for some cases |
| 28 | +
|
| 29 | +
|
| 30 | +But we can also use a Conan package that contains a copy of the MinGW compiler and use it |
| 31 | +as a ``tool_requires`` instead: |
| 32 | + |
| 33 | +.. code-block:: |
| 34 | + :caption: mingw-profile.txt |
| 35 | +
|
| 36 | + [settings] |
| 37 | + os=Windows |
| 38 | + compiler=gcc |
| 39 | + compiler.version=12 |
| 40 | + compiler.libcxx=libstdc++11 |
| 41 | + compiler.threads=posix |
| 42 | + compiler.exception=seh |
| 43 | + arch=x86_64 |
| 44 | + build_type=Release |
| 45 | +
|
| 46 | +
|
| 47 | + [tool_requires] |
| 48 | + mingw-builds/12.2.0 |
| 49 | +
|
| 50 | +
|
| 51 | +With this profile we can for example create a package in Windows with: |
| 52 | + |
| 53 | + |
| 54 | +.. code-block:: bash |
| 55 | +
|
| 56 | + # Using a basic template project |
| 57 | + $ conan new cmake_lib -d name=mypkg -d version=0.1 |
| 58 | + $ conan create . -pr=mingw |
| 59 | + ... |
| 60 | + -- The CXX compiler identification is GNU 12.2.0 |
| 61 | + ... |
| 62 | +
|
| 63 | +
|
| 64 | + ======== Testing the package: Executing test ======== |
| 65 | + mypkg/0.1 (test package): Running test() |
| 66 | + mypkg/0.1 (test package): RUN: .\example |
| 67 | + mypkg/0.1: Hello World Release! |
| 68 | + mypkg/0.1: _M_X64 defined |
| 69 | + mypkg/0.1: __x86_64__ defined |
| 70 | + mypkg/0.1: _GLIBCXX_USE_CXX11_ABI 1 |
| 71 | + mypkg/0.1: MSVC runtime: MultiThreadedDLL |
| 72 | + mypkg/0.1: __cplusplus201703 |
| 73 | + mypkg/0.1: __GNUC__12 |
| 74 | + mypkg/0.1: __GNUC_MINOR__2 |
| 75 | + mypkg/0.1: __MINGW32__1 |
| 76 | + mypkg/0.1: __MINGW64__1 |
| 77 | + mypkg/0.1 test_package |
| 78 | +
|
| 79 | +
|
| 80 | +.. seealso:: |
| 81 | + |
| 82 | + - The ConanCenter web page for the `mingw-builds package <https://conan.io/center/recipes/mingw-builds>`_ |
| 83 | + - The ``conan-center-index`` `mingw-builds Github repo recipe <https://github.com/conan-io/conan-center-index/tree/master/recipes/mingw-builds/all>`_ |
0 commit comments