<< Mac-X11 | Page list | Group map >>
This page describes how to use LyX under Cygwin on Windows by building Qt/Win and LyX from source using Cygwin tools. If you don't want or need to compile LyX yourself, you can download lyx-1.6.3-cygwin.tar.gz from the binary distribution site, un-tar it (using the cygwin tar, not native tools), and follow the instructions.
Building Qt and LyX
Note that the procedure outlined here applies to Qt 4.5.1 only. It cannot be
used with a different version, unless you adapt the provided patches.
Also note that this Qt port has only been tested with LyX and further patches
may be needed when using configuration switches different from the ones
reported here.
Cygwin packages
We need quite a slew of tools to build Qt and LyX. Be sure to install at least
the cygwin packages listed below. Due to a dependency mechanism, all other tools
not listed here should also be marked for installation (I hope I forgot nothing).
- aspell
- aspell-dev
- bison
- bzip2
- gcc
- gcc4
- gettext-devel
- gzip
- jpeg
- libpng
- libtool
- m4
- make
- minires-devel
- patch
- pkg-config
- python
- sed
- tar
Instead of using the setup program, if you've installed wget you can install everything from the command line using the apt-cyg script:
wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg
chmod a+x apt-cyg
mv apt-cyg /usr/local/bin
apt-cyg install aspell aspell-dev bison bzip2 gcc gcc4
gettext-devel gzip jpeg libpng libtool m4 make
minires-devel patch pkg-config python sed tar
Qt4 Open Source Edition
Grab the Qt sources
qt-all-opensource-src-4.5.1.tar.gz
and unpack the archive somewhere, eg. in /usr/local/src
cd /usr/local/src
tar zxvf /path/to/qt-all-opensource-src-4.5.1.tar.gz
Now rename the newly created directory
mv qt-all-opensource-src-4.5.1 qtwin-4.5.1
This step is not strictly necessary, but we will be building only for Windows
and in the following instructions it is assumed that the Qt sources are located
in a directory called qtwin-4.5.1 in /usr/local/src. If you unpacked the
sources somewhere else, simply replace /usr/local/src in the following
directions with whatever is appropriate.
In order to build Qt for cygwin simply follow the next procedure.
- Apply the qt451-cygwin.patch. This
patch allows building Qt with the native Windows graphics backend (X11 is
not required), but otherwise as a cygwin (posix compliant) application.
cd /usr/local/src/qtwin-4.5.1
patch -p1 < /path/to/qt451-cygwin.patch
- Configure Qt
cd /usr/local/src/qtwin-4.5.1
mkdir build-cygwin
cd build-cygwin
ln -s /usr/bin/make /usr/bin/gmake
../configure -prefix /usr/local/qt/4.5.1 -platform cygwin-g++-win32
-v -release -static -fast -no-qt3support -no-3dnow -no-sse2 -no-exceptions
-no-largefile -no-rpath -no-sql-ibase -no-sql-mysql -no-sql-odbc
-no-sql-psql -no-sql-sqlite -no-nis -no-cups -no-pch -no-opengl -no-glib
-no-gstreamer -no-phonon -no-webkit
Note: using the above command line, Qt will be installed in /usr/local/qt/4.5.1.
Change this path if you want to install it somewhere else.
- Compile only the Qt tools and libraries needed for building LyX
make sub-tools-bootstrap sub-moc sub-rcc sub-uic sub-corelib sub-gui
- Install tools, libraries, and include files in /usr/local/qt/4.5.1
make sub-moc-install_subtargets sub-rcc-install_subtargets
sub-uic-install_subtargets sub-corelib-install_subtargets
sub-gui-install_subtargets
- Install some additional include files that for some reason are not
automatically installed. Grab the qt-copy-includes
script and launch it as follows:
cd /usr/local/src/qtwin-4.5.1/build-cygwin
/path/to/qt-copy-includes /usr/local/qt/4.5.1
Change /usr/local/qt/4.5.1 with the actual path where you installed Qt4.
You can now move to building LyX.
LyX
- Unpack lyx-1.6.X.tar.bz2 in /usr/local/src (replace X to match your
archive name)
cd /usr/local/src
tar jxvf /path/to/lyx-1.6.X.tar.bz2
- For LyX versions less than 1.6.3, you need to apply the
gcc4.diff patch.
cd /usr/local/src/lyx-1.6.X
patch -p0 < /path/to/gcc4.diff
- Configure LyX using the script
lyxconfig-cygwin.
cd /usr/local/src
/path/to/lyxconfig-cygwin lyx-1.6.X
If you installed Qt4 somewhere else than /usr/local/qt/4.5.1, then give the
directory where you actually installed it as second parameter
/path/to/lyxconfig-cygwin lyx-1.6.X <qt4dir>
- Compile and install LyX
cd lyx-1.6.X/build-cygwin
make
make install
- Run the packaging script package-lyxcygwin
/path/to/package-lyxcygwin /usr/local/share/lyx
MikTeX, ImageMagick, and native converters
When compiled as outlined here, LyX is a cygwin application. This means
that it understands both posix and windows paths, but it always generates posix
paths. So, if you use the native MikTeX and/or ImageMagick packages, as they are
unaware of posix paths, these must be translated to native form.
The only two programs that need this translation are epstopdf (from MikTeX)
and convert (from ImageMagick). Here you can download two scripts which take
care of the translation: epstopdf,
convert. Place them ahead in your PATH
(/usr/local/bin is a good choice) such that LyX finds them before the MikTeX
and ImageMagick programs. If you use the tetex and imagemagick cygwin packages,
you don't need them.
In case you use other native converters, you may call them through the following
wrapper script: wrapper.sh. Simply give it
the same name as the native application (without any extension) and place it in
/usr/local/bin. Now, using a text editor that produces Unix line endings (notepad
is not good), go to the last line and change the string command_name to the name
of the native application. If such application is not already in the system PATH,
use an absolute path, instead (or simply add the path to the application to the
"PATH prefix:" entry in Tools->Preferences). The wrapper should be able to deal
with the vast majority of native applications and can be easily adapted if it does
not exactly fit your needs.
Reverse DVI/PDF search
The reverse search feature (also called inverse search) allows the
cursor in LyX to automatically jump to the point corresponding to a given
position in the DVI or PDF file being previewed. When a reverse search is
started (xdvi uses ctrl-click, whereas yap and SumatraPDF use double click),
the viewer calls an external program or script with two arguments, a filename
and a line number. The called program should pass this info to a running
instance of LyX. This can be done through the LyX server either by using the
named pipe, or the unix domain socket that lyx creates in its temporary
directory (this is the way the lyxclient program communicates with LyX).
The reverse search feature can be enabled in LyX as follows:
- For enabling reverse DVI search, change the
LaTeX (plain)->DVI or
LaTeX (plain)->DraftDVI converter in
Tools->Preferences->File Handling->Converters to
latex -src-specials $$i. As an alternative to redefining the
converter, insert \usepackage[active]{srcltx} in the preamble
of the LyX file.
- For enabling reverse PDF search, change the
LaTeX (pdflatex)->PDF (pdflatex)
converter in Tools->Preferences->File Handling->Converters to
pdflatex --synctex=-1 $$i. As an alternative to redefining the
converter, insert \usepackage{pdfsync} in the preamble.
Note that only SumatraPDF supports reverse PDF search, currently.
In order to allow both DVI and PDF reverse search, you can also insert
in the preamble the following lines:
\usepackage{ifpdf}
\ifpdf
\usepackage{pdfsync}
\else
\usepackage[active]{srcltx}
\fi
In this way, you can preview the file as either DVI or PDF (pdflatex)
and the right package will be used.
- If you use xdvi, you don't need do anything else, as LyX already
provides the necessary hooks for automatically using the lyxclient
program. However, if for whatever reason you want to use the named pipe
instead of the socket for communicating with LyX, simply change the DVI
viewer in
Tools->Preferences->File Handling->File formats to
xdvi -editor 'lyxeditor.sh %f %l', lyxeditor.sh being the
following script:
#!/bin/sh
LYXPIPE="/path/to/lyxpipe"
COMMAND="LYXCMD:revdvi:server-goto-file-row:$1 $2"
echo "$COMMAND" > "${LYXPIPE}".in || exit
read < "${LYXPIPE}".out || exit
where you have to substitute /path/to/lyxpipe with the LyXServer pipe path
specified in Tools->Preferences->Paths. If the LyXServer pipe path is
empty, specify one of your choice. A good choice is $HOME/.lyx/lyxpipe.
- If you use yap as a DVI viewer, you should set the name of the program that
communicates with LyX directly in yap as follows. After launching yap,
choose its "View->Options" menu and select the "Inverse DVI Search" tab.
Click on the "New..." button and, in the window which opens, enter
"LyX Editor" (or any other name you like) in the "Name:" field. Now click
on the button labeled "..." to open a filedialog and navigate to the directory
containing the batch file lyxeditor.bat (see below). Select lyxeditor.bat
and then specify the program arguments as
%f %l if you want to
use the shell script above, or as -g %f %l if you want to use the
lyxclient program (recommended). As yap is a native Windows application,
the filename it provides should be converted to posix style before being
passed to lyxeditor.sh or lyxclient, and this is the purpose of the
lyxeditor.bat wrapper, which is as follows:
@echo off
if "%1" == "-g" goto lyxclient
bash -c 'lyxeditor.sh $(cygpath -a "%1") %2'
exit
:lyxclient
bash -c 'lyxclient %1 $(cygpath -a "%2") %3'
You have to make sure that both lyxeditor.sh and lyxclient.exe are in the
command PATH, otherwise you have to use their full posix path in the above
batch file. A drawback of using a batch file is that a console window will
briefly flash after you double click in yap. If this is annoying for you,
you can instead compile the following C program
lyxeditor.c (follow the instructions
in the file for how to do that) and use the produced binary lyxeditor.exe
in place of lyxeditor.bat. The annoying console window should not flash
anymore.
- As SumatraPDF is a native Windows application (and thus
does not understand posix paths) you should use a wrapper script for launching
it. In
Tools->Preferences->File Handling->File formats->PDF (pdflatex)
specify SumatraPDF.sh as the viewer, where SumatraPDF.sh is the
following shell script:
#!/bin/bash
cd $(dirname $1)
"/cygdrive/c/Program Files/SumatraPDF/SumatraPDF.exe"
-inverse-search "\"C:\cygwin\usr\local\bin\lyxeditor.bat\"
-g \"%f\" %l" $(basename $1)
# IMPORTANT: Combine the above three lines into a single line!
with the paths adjusted appropriately. The -g enables communication
via the lyxsocket (recommended); omit the -g option if you want
to use the lyxpipe. The lyxsocket is a unix domain socket located in the
LyX temporary directory, while lyxpipe is a named pipe typically located
in ~/.lyx.
If you did no mistakes, and if src-specials are activated as previously
described, whenever you ctrl-click in xdvi, or double click in yap or
SumatraPDF, the cursor in LyX should jump to the desired location.
Contributors
History
- 13 Feb 2006 - Created.
- 22 Feb 2006 - Updated lyxconfig-cygwin and qt3-cygwin.patch. Added a new patch for path_prefix handling.
- 23 Feb 2006 - Updated list of required cygwin packages.
- 24 Feb 2006 - Added a warning about the qt3-devel cygwin package and corrected a typo.
- 26 Feb 2006 - Added a fix for empty "TeX Information" dialog when using the tetex cygwin package.
- 12 Apr 2006 - Updated patches and build procedure.
- 13 Jan 2007 - Updated to cover changes in LyX 1.4.3 and added the winpaths patch.
- 14 Aug 2007 - Updated for LyX 1.5 and Qt4.
- 11 Jan 2008 - Updated to Qt 4.3.3.
- 08 May 2009 - Updated for LyX 1.6 and Qt 4.5.1.
Cygwin