Go to page:

Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

LyX /

LyX on Cygwin

Categories: Cygwin
<< | Page list | >>

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-2.0.3-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.7.4 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
  • 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           \
    patch pkg-config python sed tar util-linux

Qt4 Open Source Edition

Grab the Qt sources qt-everywhere-opensource-src-4.7.4.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.7.4.tar.gz

Now rename the newly created directory

mv qt-everywhere-opensource-src-4.7.4 qtwin-4.7.4

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.7.4 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 qt474-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.7.4
    patch -p1 < /path/to/qt474-cygwin.patch
    
  2. Configure Qt
    cd /usr/local/src/qtwin-4.7.4
    mkdir build-cygwin
    cd build-cygwin
    
    ../configure -prefix /usr/local/qt/4.7.4 -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.7.4. 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.7.4
    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.7.4 to match the actual directory where you installed Qt):
ln -s moc.exe /usr/local/qt/4.7.4/bin/moc-qt4
ln -s uic.exe /usr/local/qt/4.7.4/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-2.0.X.tar.gz in /usr/local/src (replace X to match your archive name)
    cd /usr/local/src
    tar zxvf /path/to/lyx-2.0.X.tar.gz
    
  2. Configure LyX using the script lyxconfig-cygwin.

Note!

 There seems to be some bugs in the script lyxconfig-cygwin.

 Line 78: Invalid argument send to linker. Should be '-Wl,-s'
 Line 88: Prematurely running 'chmod u+x' on 'configure'

 Here is a patch that corrects the bugs so configure can complete.
--- lyxconfig-cygwin-orig	2012-05-11 21:44:11.000000000 +0200
+++ lyxconfig-cygwin	2012-05-11 23:20:56.000000000 +0200
@@ -75,7 +75,7 @@
 LDFLAGS="-shared-libgcc -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import"
 test "$BUILDTYPE" = "release" && {
     OPTFLAG=""
-    LDFLAGS="$LDFLAGS -Wl,s"
+    LDFLAGS="$LDFLAGS -Wl,-s"
     ASSERTIONS="--disable-assertions"
     WARNINGS="--disable-warnings"
 } || {
@@ -85,11 +85,11 @@
 }

 CONFIGURE="../configure"
-chmod u+x ${SRCDIR}/configure
 sed -e 's/gl_have_weak=yes/gl_have_weak=no/' \
     "${SRCDIR}/configure" > "${SRCDIR}/configure-cygwin"
 touch -r "${SRCDIR}/configure" "${SRCDIR}/configure-cygwin"
 mv -f "${SRCDIR}/configure-cygwin" "${SRCDIR}/configure"
+chmod u+x ${SRCDIR}/configure

 # Set up configure itself
 #========================

Usage:

 Copy the framed (blue) area above to a text file in your favorit text-editor
 and save the file as 'lyxconfig-cygwin.patch' in the the same directory
 as you downloaded lyxconfig-cygwin.
 Make sure your file is saved with unix line-endings and add a newline at the
 end of the file as 'patch' otherwise complains.
 Then run:
patch < lyxconfig-cygwin.patch
 before proceeding to the next step.

 -- Henrik Jensen 2012-05-11.
 PS. This note should probably be removed when lyxconfig-cygwin is fixed.
 PPS. The version of the buggy script has md5 checksum: b425072b64092422728c0846009fedc1
      Check with:
echo b425072b64092422728c0846009fedc1 lyxconfig-cygwin | md5sum -c -
cd /usr/local/src
/path/to/lyxconfig-cygwin lyx-2.0.X
If you installed Qt4 somewhere else than /usr/local/qt/4.7.4, then give the directory where you actually installed it as second parameter
/path/to/lyxconfig-cygwin lyx-2.0.X --qtdir=<qt4dir>
  1. Compile and install LyX
    cd lyx-2.0.X/build-cygwin
    make
    make install
    
  2. Run the packaging script package-lyxcygwin
    /path/to/package-lyxcygwin /usr/local/share/lyx
    

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, provided that SumatraPDF is in the PATH, enter SumatraPDF -inverse-search "lyxeditor -g %f %l" in the viewer setting in Tools->Preferences->File Handling->File formats->PDF (pdflatex). 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.

Forward DVI/PDF search

The forward search feature allows you to let a dvi/pdf viewer jump (near) to a position corresponding to the cursor position in LyX. Forward search is enabled in the same way as reverse search is (see the previous section) but you also need to specify in the preferences a proper command for the used viewer. If you use one of the already supported viewers, you can do this by selecting one of the predefined commands in Tools->Preferences->Output->General. There, you will find the commands to be used with xdvi, yap, and SumatraPDF (if you don't have SumatraPDF 1.9 or a later version, you need the external command CMCDDE, downloadable from ftp://ftp2.commence.com/pub/freebies/). If you use a different viewer, you will have to check whether it supports forward search and manually enter the required command in Tools->Preferences->Output->General.

After positioning the cursor in LyX, a forward search is initiated by either the Navigate->Forward search main menu entry or the Forward search context menu entry.

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.
  • 22 May 2011 - Updated for LyX 2.0 and Qt 4.7.3.
  • 28 Feb 2012 - Updated for Qt 4.7.4.

Cygwin

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2012-05-12 04:46 CEST