-Compiling LyX 2.3 for Win32 and creating Windows installer
+Compiling LyX 2.4 for Win32 and creating Windows installer
==========================================================
-It's recommended to compile LyX using Microsoft Visual C++ 2015 and CMake.
+It's recommended to compile LyX using Microsoft Visual C++ 2017 and CMake.
Compiling with Microsoft Visual C++ (MSVC)
----------------------------------------------------------------------------
- The following instructions assume the LyX source code is in C:\LyX\lyx-23
+ The following instructions assume the LyX source code is in C:\LyX\repo
You can also use another directory if you prefer.
+ For repository cloning and version control you can use Git https://git-scm.com/download/win
+ or the Team Explorer in Visual Studio 2019
-1 Install MSVC 2015
-
- If you don't have Visual C++ 2015 installed, get the free Community edition
- from https://www.visualstudio.com/. Make sure that the following two
- features are selected for installation:
- - "Visual C++" from "Programming languages" (only the first option
- "Common Tools for Visual C++ 2015" is needed)
- - "Tools and Windows SDKs" from "Windows 8.1 and Windows Phone 8.0/8.1 Tools"
- The latter one requires Windows 8.1. If you use an older windows version
- please install the "Windows Software Development Kit (SDK) für Windows 8.1"
- from https://developer.microsoft.com/en-us/windows/downloads/windows-8-1-sdk.
- This version requires at least Windows 7.
- If the build complains later that it cannot find the file
- C:\Microsoft.Cpp.Default.props then the SDK is not installed properly.
+1 Install MSVC 2019
+
+ If you don't have Visual C++ 2019 installed, get the free Community edition
+ from https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=16
+ You will need the Workload "Desktopdevelopment with C++" and you can also install Python 3
+ (either selecting Python-Development workload or just Python 3 in the individual components tab)
+ in the Visual Studio installer, so that you don't have to install it separately
+
+ You may also want to install following extensions:
+ - Qt Visual Studio Tools: enables preview of some Qt variables, like QString, while debugging
+ - Concurrency Visualizer for Visual Studio: graphically shows which thread does what and when
2 Install Qt
- Download the latest Qt for Open Source C++ development on Windows (VS2015)
+ Download the latest Qt online installer for Open Source development on Windows
from https://qt.io/download-open-source/
- Qt 5.6.x is recommended, but 5.7.x or later versions should work as well.
- If you want to build LyX as 32bit application, you need Qt x86.
- If you want to build LyX as 64bit application, you need Qt x64.
- Make sure that the bin subfolder of the Qt installation (e.g.
- C:\Qt\Qt5.6.1\5.6\msvc2015\bin) is listed in the PATH environment variable.
+ Qt 5.12.x is recommended, but 5.9.x or later versions should work as well.
+ The newest Qt is 5.12.6, in the installer you will need to expand that category and mark MSVC 2017 32-bit and/or
+ MSVC 2017 64-bit, depending on which versions of LyX you want to build.
+ Qt6 only delivers prebuild 64 bit binaries. If you install Qt6, you will also need to check
+ "Qt 5 Compatiblity Module"
+ Note, you dont need to Install the "old" 2017 build tools in Visual Studio installer,
+ the 2019 ones are compatible with MSVC 2017 kits installed with Qt.
+ Qt should install in C:\Qt.
3 Install Python
- Install the latest Python 2.x or 3.x version from
+ Install the latest Python 3.x version from
https://www.python.org/downloads/
+ Assure that you use the installer option "Add Python 3.x to PATH"
+ If you install Python through Visual Studio installer, just find it under Settings > Apps,
+ select "Change" and enable the "Add to PATH" option; or add the path, in which the python.exe
+ is located manually to the PATH environment variable, should be something like:
+ C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64
4 Install CMake
Install the latest CMake from http://www.cmake.org
-5 Configure
+5 Download dependencies
- - Open the "Developer Command Prompt for VS2015" from the
- "Visual Studio 2015\Visual Studio Tools" subfolder of the start menu.
- Run the CMake GUI from the command window that was opened.
- Alternatively, you can create a .bat file that first contains the line
- call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
- and then calls the CMake GUI and use this .bat file to start CMake.
- This is for building a 32bit LyX, if you want to build a 64bit LyX replace
- 'x86' by 'amd64'.
- The MSVC 2015 command prompt or vcvarsall.bat set some environment
- variables that are needed for CMake to find the compiler.
+ Download the LyX for Windows build dependencies from
+ http://ftp.lyx.org/pub/lyx/devel/win_deps/
+ there are 64 (lyx-windows-deps-msvc2019_64.zip) and 32 (lyx-windows-deps-msvc2019_32.zip) bit dependencies
+ and extract it e.g. to
+ C:\LyX
+ This is the later needed GNUWIN32 directory
- - Set the source code path to C:\LyX\lyx-23
- Set the build path to C:\LyX\lyx-23-build
- Click Configure and set the generator to "Visual Studio 14 2015" to
- build a 32bit LyX or "Visual Studio 14 2015 Win64" to build a 64bit LyX.
+6 Configure
- - Set LYX_USE_QT to QT5 and click Configure.
-
- - Enable LYX_DEPENDENCIES_DOWNLOAD and click Configure.
- Pre-compiled dependencies will automatically be downloaded.
- If you installed the dependencies manually, set GNUWIN32_DIR instead
- to the folder that contains the dependencies and click Configure.
+ - Open the CMake GUI
+
+ - Set the source code path to C:\LyX\repo
+ Set the build path to e.g. C:\LyX\build
+ Click Configure and set the generator to "Visual Studio 16 2019".
+ Select the platform (Win32 or x64) you wish to compile for.
- - Enable the LYX_INSTALL option and click Configure.
+ - Click on finish
+
+ - You will now get an error about missing GNUWIN32 directory.
- - Click Generate.
+ - Set GNUWIN32_DIR to the folder that contains the dependencies (keep the bit version in mind).
+ (This alternative does currently not work:
+ Enable LYX_DEPENDENCIES_DOWNLOAD and click Configure.
+ Pre-compiled dependencies will automatically be downloaded.)
-6 Compile
+ - Set LYX_USE_QT to QT5 or Qt6 depending with which one you want to compile.
+
+ - set CMAKE_PREFIX_PATH to the path of a Qt-kit
+ e.g. to C:\Qt\5.12.6\msvc2017_64 or C:\Qt\5.12.6\msvc2017 or C:\Qt\6.1.0\msvc2019_64
+ depending on which platform you have chosen
+ If you cant find this option, simply add a new entry of type "path" manually
- A Microsoft Visual C++ solution should have been generated at
- C:\LyX\lyx-23-build\lyx.sln
- Compile the INSTALL project to get a LyX installation in
- C:\LyX\lyx-23-build\LYX_INSTALLED.
+ - Disable the LYX_EXTERNAL_DTL option
-7 Copy dependencies
+ - Enable the LYX_INSTALL option and click Configure.
- Copy
- - C:\LyX\lyx-23-build\msvc2015-deps\lyx-windows-deps-msvc2015\bin
- - C:\LyX\lyx-23-build\msvc2015-deps\lyx-windows-deps-msvc2015\imagemagick
- - C:\LyX\lyx-23-build\msvc2015-deps\lyx-windows-deps-msvc2015\Python
- - C:\LyX\lyx-23-build\msvc2015-deps\lyx-windows-deps-msvc2015\ghostscript
- - C:\LyX\lyx-23-build\msvc2015-deps\lyx-windows-deps-msvc2015\Resources
- to C:\LyX\lyx-23-build\LYX_INSTALLED
+ - Click Generate.
- And copy from the Qt bin directory (see item 2 "Install Qt" above)
+7 Compile
+
+ A Microsoft Visual C++ solution should has been generated at
+ C:\LyX\build\lyx.sln
+ - Open the lyx.sln by double-clicking on it
+ - This solution file contains multiple projects in different folders.
+ - In solution explorer find the project "INSTALL" in the "CMakeTargets" folder, rightlick > Build
+ - If you get an error, that something has failed, try going Build > Build solution at the top menu bar
+ and then rebuild the INSTALL project
+
+
+8 Copy dependencies
+
+ - Compiling the INSTALL project creates the folder C:\LyX\build\LYX_INSTALLED containing the files
+ needed to run LyX
+
+ - Copy these folders:
+ C:\LyX\lyx-windows-deps-msvc2017\bin
+ C:\LyX\lyx-windows-deps-msvc2017\imagemagick
+ C:\LyX\lyx-windows-deps-msvc2017\Python
+ C:\LyX\lyx-windows-deps-msvc2017\ghostscript
+ C:\LyX\lyx-windows-deps-msvc2017\Resources
+ to C:\LyX\build\LYX_INSTALLED
+ (allow the request to overwrite)
+
+ - Go to the Qt-kit directory, which you have specified as CMAKE_PREFIX_PATH, enter the bin folder
+ Copy these files:
Qt5Core.dll
Qt5Gui.dll
Qt5Svg.dll
Qt5Widgets.dll
Qt5WinExtras.dll
+ Qt6Core5Compat.dll (if compiling with Qt6)
Qt5Cored.dll (if compiling Debug version)
Qt5Guid.dll (if compiling Debug version)
Qt5Svgd.dll (if compiling Debug version)
Qt5Widgetsd.dll (if compiling Debug version)
Qt5WinExtrasd.dll (if compiling Debug version)
- to C:\LyX\lyx-23-build\LYX_INSTALLED\bin
+ Qt6Core5Compatd.dll (if compiling with Qt6 and debug version)
+ to C:\LyX\build\LYX_INSTALLED\bin
+
+ - Go to the Qt-kit directory, which you have specified as CMAKE_PREFIX_PATH, enter the plugins folder
+ Copy these subdirectories:
+ iconengines
+ imageformats
+ platforms
+ styles
+ to C:\LyX\build\LYX_INSTALLED\bin
+
+9 Start LyX
+
+ C:\LyX\build\LYX_INSTALLED\bin\lyx.exe
-8 Define path prefix
+10 Define path prefix
- Add the following line to C:\LyX\lyx-23-build\LYX_INSTALLED\Resources\lyxrc.dist,
- so LyX will find the bundled tools such as Python, ImageMagick
- and Ghostscript:
+ In LyX use the menu Tools->Preferences
+ There input the the following the the field "Path prefix":
- \path_prefix "$LyXDir\bin;$LyXDir\Python;$LyXDir\imagemagick;$LyXDir\ghostscript"
+ "$LyXDir\bin;$LyXDir\Python;$LyXDir\imagemagick;$LyXDir\ghostscript"
You may also add the location of your LaTeX installation if it's not on the
system PATH, and the location of JabRef.
-9 Start LyX
- C:\LyX\lyx-23-build\LYX_INSTALLED\bin\lyx.exe
+Debugging
+=========
+
+ - Open LyX.sln
+
+ - In Solution Explorer open applications\LyX\LyX\main.cpp, the main function is the entry point,
+ you can e.g. place breakpoints in there.
+
+ - On the menu bar in Solution Explorer there is a button "Switch Views", click on that and choose "Folder view"
+ (to go back to normal view, click Switch Views again and choose "LyX.sln")
+
+ - In folder view find "LyX.exe" in "LYX_INSTALLED\bin" folder, rightclick > Set as Startup Item
+
+ - Start debugging with F5, clicking the Debug button (it shows now "LyX.exe") or rigchtlicking on LyX.exe in
+ Solution Explorer - Folder View and choosing "Debug".
+ (Starting debugging will have to be always with active Folder View. Attempting to start debugging with
+ normal view active will start LyX.exe located in e.g. C:\LyX\build\bin\Debug, it won't find the dependencies
+ and will therefore fail. Once debugging has started you can switch back to normal view of the Solution Explorer)
+
+ - Don't forget to build the INSTALL project each time you change the source code.
+
+
+Creating a patch file containing a bugfix
+=========================================
+
+ If you managed to fix a bug but dont have the rights to push your commits, you will want to create a patch file
+ and share it with other developers. To do so you will have to do following:
+
+ - Make sure you are working on the newest versions, pull from git before you start bugfixing.
+
+ - After fixing a bug create a commit (it will be on your local repo and not on server), choose an approproate description,
+ e.g. the ticket nr. if there is a bugreport for it
+
+ - Use this command in git bash:
+ git format-patch -1 HEAD
+ it will create a patch file in your repository folder, this is what you share.
+
+ Another usefull command is
+ git diff --cached > file.diff
+ which will create a .diff file of staged changes. There is no option for the description with it though.
Creating the Installer
======================
- - Get NSIS from http://nsis.sourceforge.net
+ - The installer is done with NSIS from http://nsis.sourceforge.net
- In the LyX source directory, go to development\Win32\packaging\installer
- - Copy the 3 dll-files from there to the DLL folder of the NSIS installation
- - Check whether the file locations/paths in settings.nsh match your setup.
- - Right-click on lyx.nsi and click "Compile NSIS Script".
+ - Follow the steps in the file Readme.txt
Compiling with GCC with MinGW64 + MSYS2 Environment using autotools