Skip to content

Building on Windows

Melonbob edited this page Jan 22, 2023 · 17 revisions

Introduction

Brewtarget is built on top of many technologies. It is programmed in C++, uses QT application framework for building graphical interfaces, uses SQLite as its embeded DBMS. It also uses CMake to generate cross-platform build targets.

Building

Prerequisite

QT

In order to build an application using QT, you must use a version of QT which has been built specifically for your target platform. There are two ways you can do this, either to download the right version from QT's website, or to build the platform yourself.

CMake

The build generator used in this project is CMake. It comes in two version: a GUI and a CLI. Both are installed by the same installer found here : CMake installer. If you use the CLI, make sure it is in your path : cmake --version.

Xerces-C and Xalan-C

MSYS / MinGW Compiler

See further down on this page under MSYS

Visual Studio / MSVC

For Visual Studio you need to clone or download and initiate the Repository from Github: https://github.com/microsoft/vcpkg
Install the packages issuing this command:

C:\vcpkg> vcpkg.exe install xerces-c:x64-windows xalan-c:x64-windows

Then add the tool chain printed out to you Cmake command below.

SQLite CLI

This may only be required when using MinGW, but download SQLite3 CLI and unzip the file somewhere in your path. I put it in the MinGW /bin directory.

Configure

CMake

GUI
Run it, and point it to the directory where the brewtarget source code is located, and also give it a blank directory to put the generated files in. Press the configure button. If cmake does not find Qt, you'll have to manually tell it where Qt is located. Press the generate button to generate the project files.
CLI

  • Create a build directory
cmake
  -G "MinGW Makefiles"
  -DDO_RELEASE_BUILD={ON or OFF depending on your choice. OFF = default}
  -DCMAKE_PREFIX_PATH={Path to QT's build of your toolchain and target. ex: D:/Programs/qt/5.4/mingw491_32}
  -DCMAKE_TOOLCHAIN_FILE={ If you're using Visual studio add this path to your toolchain. (is printed when you run vcpkg)}
  {path to brewtarget repository}

SQLite CLI

This may only be required when using MinGW, but download SQLite3 CLI and unzip the file somewhere in your path. I put it in the MinGW /bin directory.

Build

Open the project files and run the targets. The package target will generate a .exe NSIS installer.

Using MSYS2

There is an option to use a collection of tools and libraries MSYS2. It provides easy setup off all required tools for building Brewtarget in a way close as in Linux systems. After installing MSYS2 as in instruction should install some additional components. In MSYS2 terminal copy next:

pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-make mingw-w64-x86_64-gcc mingw-w64-x86_64-qt5 mingw-w64-x86_64-nsis mingw-w64-x86_64-xerces-c mingw-w64-x86_64-xalan-c mingw-w64-x86_64-boost mingw-w64-x86_64-doxygen mingw-w64-x86_64-libbacktrace

Add to environment variable PATH path to MinGW bin in MSYS2, for example: C:\msys64\mingw64

So, it's all you need to build project. Use cmake --build . in your build folder.

To install you will need to run MSYS2 MINGW64 terminal with administrator privileges or add sudo functionality into it. See this thread. Use cmake --build . --target install.

As of 2023-01-21 the MSYS2 MINGW64 will not assemble a package. You need a few additional plugins and will need the i686 version of the above components. See this thread for plugins. Use cmake --build . --target package