Skip to content

Building on macOS (Homebrew)

Stefan Löffler edited this page Mar 9, 2022 · 1 revision

Thanks to Charlie Sharpsteen for developing this guide and providing the files.

Note: This guide is still work-in-progress. If you find something is not working on your system, please drop us a mail on the mailing list <http://tug.org/mailman/listinfo/texworks>.

Preface

This document describes a procedure for building TeXworks on macOS using Homebrew <http://brew.sh/> and CMake. It is by no means the only way possible and it doesn't anticipate and tackle all possible problems, either. If you run into any difficulties feel free to ask for help on the mailing list <http://tug.org/mailman/listinfo/texworks>.

Note that compiling is usually done in the terminal. This may be unfamiliar to many Mac users, but the terminal is a powerful, very versatile, and commonly used tool for software development. Don't worry, however, as this guide will walk you through each step.

Prerequisites

The basic requirements are Homebrew and Xcode. For a more in-depth guide, see <https://brew.sh/> and <https://docs.brew.sh/Installation>.

If you have some of the prerequisites installed already, you can skip the respective sections, of course.

Xcode

Xcode is Apple's integrated development environment that provides (among other things) the compiler necessary to build libraries and TeXworks itself. It is available at <http://developer.apple.com/xcode/>.

Homebrew

Homebrew claims to be "the Missing Package Manager for macOS (or Linux)". In this guide, it is used to get the libraries necessary to build TeXworks.

To install Homebrew, full the one-line instruction at <https://brew.sh/> which will download and run the installation script.

Obtaining necessary tools and libraries

For building TeXworks, you need several tools and libraries, namely:

  • git: used to keep track of the TeXworks sources and build scripts
  • pkg-config: is used by the build scripts to find libraries
  • CMake: interprets and executes the build scripts
  • Qt: the toolkit which is used to build the graphical user interface
  • hunspell: a spellchecking library
  • poppler: a library for displaying PDF files
  • lua (optional): a programming language that can be used for scripts in TeXworks

To install these, run the following command in a terminal:

brew install hunspell poppler lua qt

Warning: Some of these will take a long time to finish. Especially Qt is quite large (several 100s of MB), so make sure you have a good internet connection and (up to) a couple of hours. The good thing is that each installation should run without requiring any input from you.

Obtaining and building TeXworks

To obtain the TeXworks sources themselves and the corresponding build scripts, run

git clone https://github.com/TeXworks/texworks.git
cd texworks

This will download the required files, put them into a folder named texworks that is created in the current folder, and change directory into the newly created texworks folder.

To configure and build TeXworks, run

cmake -B build -S . -DQT_DEFAULT_MAJOR_VERSION=6
cmake --build build

If you want to install TeXworks, you can use the following command:

cmake --install build

Updating TeXworks

To update TeXworks, again navigate to the texworks directory and run the following commands:

git pull
cmake --build build

and possibly

cmake --install build

From time to time, you should also check if some of you Homebrew packages are out-of-date. To do that, run the following commands:

brew update
brew outdated