-
Notifications
You must be signed in to change notification settings - Fork 135
Development: Getting Started
These notes are written on the assumption that you're developing on Linux. Developing on Windows or Mac should be pretty similar, but a few of the details might differ slightly. See Building on Windows for one way to get set up on Windows.
To build Brewken, you will need a mainstream C++ compiler (in particular for which cmake can generate project files or makefiles) such as g++ or clang++. You will also need the following (see below on how to install):
- CMake version 3.16 or newer
- Git
- Boost version 1.75 or newer
- Xerces-C++
- Xalan-C++
- Doxygen to build the HTML documentation from special comments in the source code
- Qt development libraries (version 5.9.5 or newer).
On Debian systems like Ubuntu, you can install all the above (except Boost -- see below) by installing the following packages (with sudo apt install
or similar):
cmake
doxygen
git
libqt5multimedia5-plugins
libqt5sql5-psql
libqt5sql5-sqlite
libqt5svg5
libqt5svg5-dev
libxalan-c-dev
libxalan-c-doc
libxerces-c-dev
libxerces-c-doc
qtbase5-dev
qtmultimedia5-dev
qttools5-dev
qttools5-dev-tools
If you want to build the install packages (rather than just install locally with make install
), you'll also need:
-
debhelper
to build .deb packages for Debian/Ubuntu -
lintian
to validate .deb packages -
rpm
to build RPMs -
rpmlint
to validate RPMs
(The following are no longer needed, though you may see reference to them in old comments: qt5-default, libqt5webkit5-dev)
After using git to clone your brewtarget repository into ~/brewtarget/
,
$ cd ~
$ mkdir build
$ cd build
$ cmake ../brewtarget
$ make
We ideally need a recent version of Boost, ie Boost 1.75 or newer. (This will definitely be the case when we add support for BeerJSON.) For Windows and Mac this is fine if you are installing from MSYS2 or Homebrew respectively. Unfortunately, as of late-2021, many Linux distros provide only older versions of Boost (eg, Ubuntu 20.04.3 LTS offers Boost 1.71, as can be seen by running dpkg -s libboost-dev | grep 'Version'
).
To install the latest version of Boost from source, first uninstall any old version installed via your distro (eg, on Ubuntu, this means sudo apt remove libboost-all-dev
), then follow the instructions at boost.org. Eg, for Boost 1.77 on Linux, this means the following (assuming you want headers in /usr/include and libraries in /usr/lib):
$ cd ~
$ mkdir boost-tmp
$ cd boost-tmp
$ wget https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2
$ tar --bzip2 -xf boost_1_77_0.tar.bz2
$ cd boost_1_77_0
$ ./bootstrap.sh --prefix=/usr
$ sudo ./b2 install
$ cd ../..
$ rm -rf boost-tmp
These instructions for Mac are a bit out of date... On mac, you need to install Xcode, cmake, git, sqlite3 (should already be installed), and Qt 4.8 (both the standard libraries and debug libraries ). Xcode 4.2.1 seems to work for OSX 10.7.2.
Download and install all of these packages except Qt. Follow the instructions below when installing Qt.
Be sure to completely install Xcode first. The Xcode "installer" just installs an icon in the Applications directory to really install Xcode. If you install Qt before completing the Xcode installation, all the Qt stuff will get moved from /Developer
to /Developer-old
. If you do not heed this instruction, you will find that cmake
gives you an error like:
Could NOT find Qt4 (missing: QT_MOC_EXECUTAbLE QT_RCC_EXECUTABLE
QT_UIC_EXECUTABLE) (found suitable version "4.8.5", minimum required is
"4.6.0")
If it goes to /Developer-old
by accident, you can copy all the Qt folders into the appropriate /Developer
directory, for example: /Developer-old/Applications/Qt
-> /Developer/Applications/Qt
. Or, you can just brute force it:
$ cp -a -n /Developer-old/* /Developer/
$ rm -rf /Developer-old
This is a cmake project, whose project files CMakeLists.txt are present in each source directory. As such, all you need for a good development environment is a good text editor (kate, gedit, notepad++, vim, etc.) and a command line to run cmake (or optionally one of the cmake GUIs). Qt Creator can read the CMakeLists.txt as a project file, but we highly discourage using Qt Creator to create new files to add to the project, because it edits the CMakeLists.txt file in very strange ways. If you must use it, use it only to modify existing files.
You will need Qt Designer for editing the .ui files that describe each GUI element in the project.