Go to page:

Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

LyX /

LyX on Cygwin

Categories: Cygwin
<< 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.5-cygwin.tar.gz from the binary distribution site, un-tar it (using the cygwin tar, not native tools), and follow the instructions. Note that official Cygwin packages for the various Qt4 libraries are now available in the Cygwin distribution for the X11 backend, so, if you want a Qt4/X11 version, you can simply install one or more of those. Instead, if you want a cygwin version of Qt4 but using the native Windows graphics backend, you can continue reading.

Building Qt and LyX

Please note that the procedure outlined here applies to Qt 4.6.2 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
  • util-linux

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 util-linux

Qt4 Open Source Edition

Grab the Qt sources qt-everywhere-opensource-src-4.6.2.tar.gz and unpack the archive somewhere, eg. in /usr/local/src

cd /usr/local/src
tar zxvf /path/to/qt-everywhere-opensource-src-4.6.2.tar.gz

Now rename the newly created directory

mv qt-everywhere-opensource-src-4.6.2 qtwin-4.6.2

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.6.2 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.

  1. Apply the qt462-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.6.2
    patch -p1 < /path/to/qt462-cygwin.patch
    
  2. Configure Qt
Note: if you have installed one of the Qt4 devel packages from the Cygwin distribution, before proceeding you need to unset the QMAKESPEC environment variable and make sure that it will not be set in subshells (that are spawned during the configure process) by some script in /etc/profile.d. For example, this is achieved by the following commands:
unsetenv QMAKESPEC    # if you use tcsh
unset QMAKESPEC       # if you use bash
mv /etc/profile.d/libQtCore4-devel.csh /etc/profile.d/libQtCore4-devel.csh.no
mv /etc/profile.d/libQtCore4-devel.sh /etc/profile.d/libQtCore4-devel.sh.no
If you have not installed any Qt4 devel package, you can simply proceed as follows:
cd /usr/local/src/qtwin-4.6.2
mkdir build-cygwin
cd build-cygwin

../configure -prefix /usr/local/qt/4.6.2 -platform cygwin-g++-win32            \
    -release -static -fast -qt-sql-sqlite -no-reduce-exports -no-qt3support    \
    -no-exceptions -no-largefile -no-rpath -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.6.2. Change this path if you want to install it somewhere else.
  1. 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
    
  2. Install tools, libraries, and include files in /usr/local/qt/4.6.2
    make sub-moc-install_subtargets sub-rcc-install_subtargets     \
         sub-uic-install_subtargets sub-corelib-install_subtargets \
         sub-gui-install_subtargets
    
Note: if you have installed one of the Qt4 devel packages from the Cygwin distribution, you have to create the following symlinks (change /usr/local/qt/4.6.2 to match the actual directory where you installed Qt):
ln -s moc.exe /usr/local/qt/4.6.2/bin/moc-qt4
ln -s uic.exe /usr/local/qt/4.6.2/bin/uic-qt4
otherwise, when configuring for LyX, the wrong moc and uic compilers will be picked.
  1. Optionally install qmake and Qt specs
    make install_qmake install_mkspecs
    

You can now move to building LyX.

LyX

  1. 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
    
  2. 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.6.2, then give the directory where you actually installed it as second parameter
/path/to/lyxconfig-cygwin lyx-1.6.X --qtdir=<qt4dir>
  1. Compile and install LyX
    cd lyx-1.6.X/build-cygwin
    make
    make install
    
  2. 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 a named pipe (lyxpipe), or the unix domain socket (lyxsocket) 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 lyxpipe instead of the lyxsocket for communicating with LyX, simply change the DVI viewer in Tools->Preferences->File Handling->File formats to xdvi -editor 'lyxeditor %f %l', and be sure to specify the LyXServer pipe path in Tools->Preferences->Paths (a good choice is $HOME/.lyx/lyxpipe). You should find the lyxeditor.exe program in /usr/local/bin, as it is installed by default on Cygwin.
  • If you use yap as a DVI viewer, you should make sure that it is your default DVI viewer in the Windows environment and then 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 lyxeditor.exe program (most likely it is C:\cygwin\usr\local\bin). Select lyxeditor.exe and then specify the program arguments as -g %f %l. In this way you will be using the lyxsocket for communicating with LyX. If, for whatever reason, you want to use the lyxpipe, omit -g, and be sure to specify the LyXServer pipe path in the LyX preferences.
  • In order to use SumatraPDF for inverse search, enter SumatraPDF.sh in the viewer setting in Tools->Preferences->File Handling->File formats->PDF (pdflatex), where SumatraPDF.sh is the following shell script (to be placed in /usr/local/bin):
    #!/bin/bash
    cd $(dirname $1)
    "/path/to/SumatraPDF.exe" -inverse-search "lyxeditor -g %f %l" $(basename $1)
    
    with the path to SumatraPDF.exe adjusted appropriately (the quotes around the path may be omitted if the path does not contain spaces but you should anyway use forward slashes). This wrapper script is needed because SumatraPDF is a native Windows application and does not understand the posix paths used by the Cygwin version of LyX. The -g enables communication via the lyxsocket (recommended); omit the -g option if you want to use the lyxpipe, and be sure to specify the LyXServer pipe path in the LyX preferences.

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

  • Enrico Forestieri

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 for Qt 4.3.3.
  • 08 May 2009 - Updated for LyX 1.6 and Qt 4.5.1.
  • 04 July 2009 - Updated for Qt 4.5.2.
  • 08 Oct 2009 - Updated for LyX 1.6.5 and Qt 4.5.3.
  • 15 Jan 2010 - Updated for Qt 4.6.0.
  • 06 Mar 2010 - Updated for Qt 4.6.2.

Cygwin

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2010-03-06 20:32 CET