Skip to content

Instantly share code, notes, and snippets.

@Mebus
Forked from Bluexin/msys2.md
Created November 3, 2021 15:59
Show Gist options
  • Save Mebus/77000406ed64d57532be57c4c244953e to your computer and use it in GitHub Desktop.
Save Mebus/77000406ed64d57532be57c4c244953e to your computer and use it in GitHub Desktop.
Setting up qtcreator with msys2 on windub

Windows

Common steps :

  • Install MSYS2-x86_64
  • At the end of the installation, run it (either automatically or manually)
  • Execute the command pacman -Syu to update core packages, then close the terminal when prompted
  • Run it again, and execute pacman -Su to update some more packages I will refer to the MSYS2 installation path as MSYS2_PATH. By default it is c:/msys64 on 64-bits systems.

32bits target (win)

Run MSYS2 MinGW 32-bit

  • cd (or pushd) to the directory you cloned this repo to
  • Execute pacman --needed -S mingw-w64-i686-toolchain mingw-w64-i686-qwt-qt5 (pacman will prompt about what packages to install, just press [enter])
  • Done!

To use this toolchain, point CMake to (MSYS2_PATH)/mingw32 (not needed with QtCreator, see instructions below)

64bits target (win)

Run MSYS2 MinGW 64-bit

  • cd (or pushd) to the directory you cloned this repo to
  • Execute pacman --needed -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-qwt-qt5 (pacman will prompt about what packages to install, just press [enter])
  • Done!

To use this toolchain, point CMake to (MSYS2_PATH)/mingw64 (not needed with QtCreator, see instructions below)

Setting up QtCreator

  1. Open the "Build & Run" panel in QtCreator options
  2. In the "Qt Versions" tab, add a new one pointing to (MSYS2_PATH)/mingw(32/64)/bin/qmake.exe (usually C:\msys64\mingw64\bin\qmake.exe)
  3. In the "Compilers" tab, add a new one for MinGW C and C++, respectively pointing to (MSYS2_PATH)/mingw(32/64)/bin/gcc.exe and .../g++.exe
  4. In the "Debuggers" tab, add a new one pointing to (MSYS2_PATH)/mingw(32/64)/bin/gdb.exe
  5. In the "CMake" tab, add a new one pointing to (MSYS2_PATH)/mingw(32/64)/bin/cmake.exe
  6. In the "Kits" tab, add a new one where you use the compilers, debugger, qt and cmake defined above
  7. Select "CodeBlocks - Ninja" as CMake Generator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment