-
Notifications
You must be signed in to change notification settings - Fork 132
Building on Windows (MinGW)
This document describes a procedure for building TeXworks on Windows using the (freely available) Minimalist Gnu for Windows (MinGW) suite together with the (also freely available) Minimal System (MSYS) command line system. If you just want to use TeXworks (rather than contribute to its development), have a look at the precompiled Windows builds.
The method for compiling TeXworks from source documented here is by no means the only one 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>.
Although TeXworks itself has only about 23 MB, the whole setup with programs, tools, and libraries will require roughly 2 GB of disk space.
Note: This guide was originally designed for the English version of Windows XP. If you use a newer version of Windows or another language, the labels and some of the paths may be different.
The following directory layout is used throughout this guide. If you choose another layout, you have to adjust the paths in the rest of this guide, of course.
C:\MinGW\ (MinGW)
C:\MinGW\msys\1.0 (MSYS)
C:\Program Files\GnuWin32 (GNU libraries)
C:\Qt\ (Qt libraries)
C:\texworks\hunspell-1.3.3\ (hunspell sources)
C:\texworks\poppler-0.28.1 (poppler sources)
C:\texworks\texworks\ (TeXworks)
C:\texworks\libs (libraries)
Most of these directories will be created automatically in the procedure outlined below, but C:\texworks
needs to be created manually.
The process described here has been sucessfully implemented using the following software.
- Git <http://git-scm.com/>
for obtaining the TeXworks source code (the command line tools are sufficient and will be used in this guide) - CMake <http://www.cmake.org/>
is the build system used to build some required libraries and the program itself. - MinGW and MSYS <http://www.mingw.org/>
contain the compiler used for building some required libraries and the program itself. There are some installation notes in the next subsection. - 7-Zip <http://www.7-zip.org/>
= 4.61 for opening tar.gz and tar.xz files.
Note: You need administrator's privileges to install new software.
Download mingw-get-setup.exe <http://sourceforge.net/projects/mingw/files/latest/download?source=files> and run it. Follow the instructions to automatically download, install, and run the MinGW Installation Manager. From the MinGW Installation Manager, mark the following packages for installation (click on the box next to the package name and select "Mark for Installation"):
- mingw32-base
- mingw32-gcc-g++
- msys-base
Install the packages by selecting "Installation" > "Apply Changes" from the menu.
Finally, add C:\MinGW\bin
to the PATH environment variable (see Q&A section).
In addition to the programs mentioned previously, you will also need several libraries that provide functionalities that TeXworks depends on.
Several libraries from the GNU project are required to build the other libraries and TeXworks itself. They can be obtained from <http://gnuwin32.sourceforge.net/packages.html>:
- freetype
- libjpeg
- libpng
- libtiff
- zlib
For each package, click on "Setup" to download the setup file, run it, follow the on-screen instructions, and make sure you install the "Binaries" and "Developer files".
Hunspell is used for spell-checking. Its sources can be obtained from <http://hunspell.sourceforge.net/>. The .tar.gz file can be extracted with 7-Zip to C:\texworks
.
To build hunspell, run MSYS by executing C:\MinGW\msys\1.0\msys.bat
. In the terminal window that opens, run the following commands:
cd /c/texworks/hunspell-1.3.3
./configure --prefix=/c/texworks/libs
cd src/hunspell
make install
This will build hunspell and install it in C:\texworks\libs
.
Qt is the underlying framework that handles all windows, dialogs, and user interaction. To obtain is, go to <http://www.qt.io/download/>, choose the (free) "Community" version (TeXworks is licensed under the GPL), download the Qt Online Installer for Windows, start it, and follow the on-screen instructions. The following components are required:
- Qt (any version) > MinGW (32 bit)
- Tools > Qt Creator
You can safely uncheck all other components to save download bandwith and disk space.
Note: The MinGW version of Qt should match the MinGW version installed above.
Poppler is used to process and display PDF files. Its sources can be obtained from <http://poppler.freedesktop.org/>. The .tar.xz file can be extracted with 7-Zip to C:\texworks
. Also download the poppler encoding data - it will be needed later on - and extract the .tar.gz file to C:\texworks
.
In order to add support for the 14 PDF base fonts (not all of which are available in Windows by default), open the file C:\texworks\poppler-0.28.1\poppler\GlobalParamsWin.cc
(e.g., in Qt Creator) and replace the line
if (dir) {
by
if (dir && displayFontTab[i].t1FileName) {
and the line
setupBaseFonts(NULL);
by
char fontsPath[MAX_PATH];
GetModuleFileName(NULL, fontsPath, MAX_PATH);
unsigned char * p = _mbsrchr ((unsigned char*)fontsPath, '\\');
*p = '\0';
strcat(fontsPath, "\\share\\fonts");
setupBaseFonts(fontsPath);
To build poppler, run "CMake (cmake-gui)" from the start menu and set the following values:
Where is the source code: C:/texworks/poppler-0.28.1
Where to build the binaries: C:/texworks/poppler-0.28.1/build
Then, add the following variables by clicking on "Add Entry":
CMAKE_PREFIX_PATH (string) = C:/Program Files/GnuWin32;C:/Qt/5.3/mingw482_32/lib/cmake
CMAKE_INSTALL_PREFIX (path) = C:/texworks/libs
ENABLE_CPP (bool) = False
ENABLE_XPDF_HEADERS (bool) = True
POPPLER_DATADIR (string) = share/poppler
If you are working on Windows XP, you additionally need to set
CMAKE_CXX_FLAGS (string) = -D_WIN32_WINNT=0x0500
Then, click on "Configure". When asked to create the build directory, select "Yes". When asked for a generator, select "MinGW Makefiles" and "Use default native compilers". When the configuration is finished, click "Generate".
Next, open a command prompt window and execute the following commands:
cd C:\texworks\poppler-0.28.1\build
mingw32-make install
Lua is an additional scripting language that can be used in TeXworks, but is optional. If you want to obtain Lua, go to <http://luabinaries.sourceforge.net/download.html> and grab the "Windows x86 DLL and Includes (MinGW 4 Comptabible)".
Unpack the .a file to C:\texworks\libs\lib
, the .dll file to C:\texworks\libs\bin
, and all files in the include directory to C:\texworks\libs\include
.
In order to get the TeXworks sources, open a command prompt and execute the following commands:
cd C:\texworks
git clone https://github.com/TeXworks/texworks.git
To build TeXworks, start by running "CMake (cmake-gui)" from the start menu and set the following values:
Where is the source code: C:/texworks/texworks
Where to build the binaries: C:/texworks/texworks/build
Then, add the following variables by clicking on "Add Entry":
CMAKE_PREFIX_PATH (string) = C:/Program Files/GnuWin32;C:/Qt/5.3/mingw482_32/lib/cmake;C:/texworks/libs
DESIRED_QT_VERSION (string) = 5
BUILD_SHARED_PLUGINS (bool) = False
Then, click on "Configure". When asked to create the build directory, select "Yes". When asked for a generator, select "MinGW Makefiles" and "Use default native compilers". The configuration process takes a while, so be patient. When the configuration is finished, click "Generate".
Next, open a command prompt window and execute the following commands:
cd C:\texworks\texworks\build
mingw32-make
Once the compilation finishes, you can find TeXworks.exe in C:\texworks\texworks\build
. To run it, copy the following files to the same directory as TeXworks.exe:
C:\Program Files\GnuWin32\bin\freetype6.dll
C:\Program Files\GnuWin32\bin\jpeg62.dll
C:\Program Files\GnuWin32\bin\libpng3.dll
C:\Program Files\GnuWin32\bin\libtiff3.dll
C:\Qt\5.3\mingw482_32\bin\icudt52.dll
C:\Qt\5.3\mingw482_32\bin\icuin52.dll
C:\Qt\5.3\mingw482_32\bin\icuuc52.dll
C:\Qt\5.3\mingw482_32\bin\libwinpthread-1.dll
C:\Qt\5.3\mingw482_32\bin\Qt5Core.dll
C:\Qt\5.3\mingw482_32\bin\Qt5Gui.dll
C:\Qt\5.3\mingw482_32\bin\Qt5Script.dll
C:\Qt\5.3\mingw482_32\bin\Qt5ScriptTools.dll
C:\Qt\5.3\mingw482_32\bin\Qt5Widgets.dll
C:\Qt\5.3\mingw482_32\bin\Qt5Xml.dll
C:\texworks\libs\bin\libhunspell-1.3-0.dll
C:\texworks\libs\bin\libpoppler-qt5.dll
C:\texworks\libs\bin\libpoppler.dll
To be able to correctly display CJK documents, you additionally need to create the folders "share/poppler" in the same directory as TeXworks.exe and copy all folders from C:\texworks\poppler-data-0.4.7
into it. To correctly display all 14 PDF base fonts, you need to copy the folder C:\texworks\texworks\win32\fonts
to C:\texworks\texworks\build\share
.
If you built TeXworks with Lua support, you additionally need to copy C:\texworks\libs\bin\lua52.dll
.
Note that scripting plugins like Lua are deactivated by default for security reasons. To activate them, go to Edit > Preferences > Scripts and check "Enable plug-in scripting languages".
In order to update TeXworks, make sure it is not currently running, open a command prompt and execute the following commands:
cd C:\texworks\texworks
git pull
mingw32-make
Usually, this should be sufficient to update the sources and recompile TeXworks. In some rare cases (in particular when there were major changes to the build system), you may need to remove C:\texworks\texworks\build\CMakeCache.txt
and reconfigure the TeXworks build system with cmake-gui as described above.
How do I add/edit an environment variable?
Right-click on "My Computer" and select "Preferences". Select the "Advanced" tab and click on the button labeled "Environment variables". Note that if an environment variable contains a list of values (e.g. paths), the values are typically separated by a semicolon (";") character. If you have any open command prompt windows, you need to close and reopen them before the changes are applied.
When running mingw32-make, Windows complains that this command is not recognized. Why?
You need to add
C:\MinGW\bin
to your PATH environmental variable.
I have a question not answered here. What shall I do?
Ask the question on the mailing list <http://tug.org/mailman/listinfo/texworks>.