1 Compiling LyX 2.4 for Win32 and creating Windows installer
2 ==========================================================
4 It's recommended to compile LyX using Microsoft Visual C++ 2017 and CMake.
7 Compiling with Microsoft Visual C++ (MSVC)
8 ===================================
10 The easiest way to install LyX with MSVC is to follow this Wiki page:
12 http://wiki.lyx.org/Windows/Compilation
14 If you find there any errors please write a mail to the lyx-devel mailing list.
16 ----------------------------------------------------------------------------
18 The following instructions assume the LyX source code is in C:\LyX\repo
19 You can also use another directory if you prefer.
20 For repository cloning and version control you can use Git https://git-scm.com/download/win
21 or the Team Explorer in Visual Studio 2019
25 If you don't have Visual C++ 2019 installed, get the free Community edition
26 from https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=16
27 You will need the Workload "Desktopdevelopment with C++" and you can also install Python 3
28 (either selecting Python-Development workload or just Python 3 in the individual components tab)
29 in the Visual Studio installer, so that you don't have to install it separately
31 You may also want to install following extensions:
32 - Qt Visual Studio Tools: enables preview of some Qt variables, like QString, while debugging
33 - Concurrency Visualizer for Visual Studio: graphically shows which thread does what and when
37 Download the latest Qt online installer for Open Source development on Windows
38 from https://qt.io/download-open-source/
39 Qt 5.12.x is recommended, but 5.9.x or later versions should work as well.
40 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
41 MSVC 2017 64-bit, depending on which versions of LyX you want to build.
42 Note, you dont need to Install the "old" 2017 build tools in Visual Studio installer,
43 the 2019 ones are compatible with MSVC 2017 kits installed with Qt.
44 Qt should install in C:\Qt.
48 Install the latest Python 3.x version from
49 https://www.python.org/downloads/
50 Assure that you use the installer option "Add Python 3.x to PATH"
51 If you install Python through Visual Studio installer, just find it under Settings > Apps,
52 select "Change" and enable the "Add to PATH" option; or add the path, in which the python.exe
53 is located manually to the PATH environment variable, should be something like:
54 C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64
58 Install the latest CMake from http://www.cmake.org
60 5 Download dependencies
62 Download the LyX for Windows build dependencies from
63 http://ftp.lyx.org/pub/lyx/devel/win_deps/
64 there are 64 (lyx-windows-deps-msvc2019_64.zip) and 32 (lyx-windows-deps-msvc2019_32.zip) bit dependencies
65 and extract it e.g. to
67 This is the later needed GNUWIN32 directory
73 - Set the source code path to C:\LyX\repo
74 Set the build path to e.g. C:\LyX\build
75 Click Configure and set the generator to "Visual Studio 16 2019".
76 Select the platform (Win32 or x64) you wish to compile for.
80 - You will now get an error about missing GNUWIN32 directory.
82 - Set GNUWIN32_DIR to the folder that contains the dependencies (keep the bit version in mind).
83 (This alternative does currently not work:
84 Enable LYX_DEPENDENCIES_DOWNLOAD and click Configure.
85 Pre-compiled dependencies will automatically be downloaded.)
87 - Set LYX_USE_QT to QT5.
89 - set CMAKE_PREFIX_PATH to the path of a Qt-kit
90 e.g. to C:\Qt\5.12.6\msvc2017_64 or C:\Qt\5.12.6\msvc2017 depending on which platform you have chosen
91 If you cant find this option, simply add a new entry of type "path" manually
93 - Disable the LYX_EXTERNAL_DTL option
95 - Enable the LYX_INSTALL option and click Configure.
101 A Microsoft Visual C++ solution should has been generated at
103 - Open the lyx.sln by double-clicking on it
104 - This solution file contains multiple projects in different folders.
105 - In solution explorer find the project "INSTALL" in the "CMakeTargets" folder, rightlick > Build
106 - If you get an error, that something has failed, try going Build > Build solution at the top menu bar
107 and then rebuild the INSTALL project
112 - Compiling the INSTALL project creates the folder C:\LyX\build\LYX_INSTALLED containing the files
115 - Copy these folders:
116 C:\LyX\lyx-windows-deps-msvc2017\bin
117 C:\LyX\lyx-windows-deps-msvc2017\imagemagick
118 C:\LyX\lyx-windows-deps-msvc2017\Python
119 C:\LyX\lyx-windows-deps-msvc2017\ghostscript
120 C:\LyX\lyx-windows-deps-msvc2017\Resources
121 to C:\LyX\build\LYX_INSTALLED
122 (allow the request to overwrite)
124 - Go to the Qt-kit directory, which you have specified as CMAKE_PREFIX_PATH, enter the bin folder
131 Qt5Cored.dll (if compiling Debug version)
132 Qt5Guid.dll (if compiling Debug version)
133 Qt5Svgd.dll (if compiling Debug version)
134 Qt5Widgetsd.dll (if compiling Debug version)
135 Qt5WinExtrasd.dll (if compiling Debug version)
136 to C:\LyX\build\LYX_INSTALLED\bin
138 - Go to the Qt-kit directory, which you have specified as CMAKE_PREFIX_PATH, enter the plugins folder
139 Copy these subdirectories:
144 to C:\LyX\build\LYX_INSTALLED\bin
148 C:\LyX\build\LYX_INSTALLED\bin\lyx.exe
150 10 Define path prefix
152 In LyX use the menu Tools->Preferences
153 There input the the following the the field "Path prefix":
155 "$LyXDir\bin;$LyXDir\Python;$LyXDir\imagemagick;$LyXDir\ghostscript"
157 You may also add the location of your LaTeX installation if it's not on the
158 system PATH, and the location of JabRef.
166 - In Solution Explorer open applications\LyX\LyX\main.cpp, the main function is the entry point,
167 you can e.g. place breakpoints in there.
169 - On the menu bar in Solution Explorer there is a button "Switch Views", click on that and choose "Folder view"
170 (to go back to normal view, click Switch Views again and choose "LyX.sln")
172 - In folder view find "LyX.exe" in "LYX_INSTALLED\bin" folder, rightclick > Set as Startup Item
174 - Start debugging with F5, clicking the Debug button (it shows now "LyX.exe") or rigchtlicking on LyX.exe in
175 Solution Explorer - Folder View and choosing "Debug".
176 (Starting debugging will have to be always with active Folder View. Attempting to start debugging with
177 normal view active will start LyX.exe located in e.g. C:\LyX\build\bin\Debug, it won't find the dependencies
178 and will therefore fail. Once debugging has started you can switch back to normal view of the Solution Explorer)
180 - Don't forget to build the INSTALL project each time you change the source code.
183 Creating a patch file containing a bugfix
184 =========================================
186 If you managed to fix a bug but dont have the rights to push your commits, you will want to create a patch file
187 and share it with other developers. To do so you will have to do following:
189 - Make sure you are working on the newest versions, pull from git before you start bugfixing.
191 - After fixing a bug create a commit (it will be on your local repo and not on server), choose an approproate description,
192 e.g. the ticket nr. if there is a bugreport for it
194 - Use this command in git bash:
195 git format-patch -1 HEAD
196 it will create a patch file in your repository folder, this is what you share.
198 Another usefull command is
199 git diff --cached > file.diff
200 which will create a .diff file of staged changes. There is no option for the description with it though.
203 Creating the Installer
204 ======================
206 - The installer is done with NSIS from http://nsis.sourceforge.net
207 - In the LyX source directory, go to development\Win32\packaging\installer
208 - Follow the steps in the file Readme.txt
211 Compiling with GCC with MinGW64 + MSYS2 Environment using autotools
212 ===================================================================
213 1 Install MSYS2, MINGW64, Qt5+
214 https://wiki.qt.io/MSYS2
215 2 Install bc (Bench calculater), which autotools uses for some reason to compile LyX
217 3 Run the standard autotools install (Adapt paths and arguments accordingly)
219 ./configure --without-x --enable-qt5 --disable-debug --enable-optimization --prefix=/mingw64
224 Cross-Compiling on unix with MXE using autotools
225 =================================================
226 1 Install MXE: http://mxe.cc
227 You can either install from sources, the generic .tar binaries or debian .deb packages.
228 Installing the following .deb packages will drag in all needed dependencies:
229 mxe-x86-64-w64-mingw32.shared-file
230 mxe-x86-64-w64-mingw32.shared-gcc
231 mxe-x86-64-w64-mingw32.shared-libiconv
232 mxe-x86-64-w64-mingw32.shared-qtimageformats
233 mxe-x86-64-w64-mingw32.shared-qtsvg
234 mxe-x86-64-w64-mingw32.shared-qtwinextras
235 Of course you can also use the static and/or 32bit versions.
236 2 Run the standard autotools install (Adapt paths and arguments accordingly)
240 PATH="/usr/lib/mxe/usr/bin:$PATH" ../configure --host=x86-64-w64-mingw32.shared --with-qt-dir=/usr/lib/mxe/usr/x86_64-w64-mingw32.shared/qt5 --enable-qt5 --with-included-boost --with-included-hunspell --with-included-mythes --disable-debug --enable-optimization --prefix=/mingw64
241 PATH="/usr/lib/mxe/usr/bin:$PATH" make
242 PATH="/usr/lib/mxe/usr/bin:$PATH" DESTDIR=/tmp/lyxinstall make install
243 This uses the paths from the 64bit shared MXE version installed from .deb packages.
244 3 If you want to run the resulting lyx.exe from the build directory using wine,
245 create symlinks for all needed .dlls:
246 cd builddir-mingw/src
247 ln -s /usr/lib/mxe/usr/x86_64-w64-mingw32.shared/bin/*.dll .
248 ln -s /usr/lib/mxe/usr/x86_64-w64-mingw32.shared/qt5/bin/*.dll .