Cross-compiling Praat under Linux for Windows (XP, 7)

DISCLAIMER

Following these instructions could render your computer unfunctional. It also might destroy data stored on your computer or make data inaccessible.

THESE INSTRUCTIONS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE INSTRUCTIONS IS WITH YOU. SHOULD THE INSTRUCTIONS PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.



Introduction

This document describes how to compile the Praat source code under Linux in order to get an executable for Windows XP, 7 or higher. The instructions are tested for Lubuntu Linux (version 14.04 LTS), therefore they should work for Debian, Ubuntu (and relatives) and Mint as well. It is assumed that the reader is familiar with Linux.

We wil use Praat 5.4.15 and and compile the source code by using mingw-w64 version 3.2.0-2 with gcc and g++ compilers version 4.8.

We describe both the procedure for 32-bit and 64 bit. Where instructions differ, the 32-bit instructions are given in green, and the 64-bit instructions in red.

The whole process consists of nine steps, which are described below one by one.



1. Install mingw-w64

Open a terminal and type:

sudo apt-get install mingw-w64

It is also possible to install via the Synaptic Pacakge Manager. Search for mingw and check mingw-w64. Click on Apply.



2. Replace intrin-impl.h



Replace intrin-impl.h in /usr/share/mingw-w64/include/psdk_inc/ . In order to do so, download intrin-impl.h here. Then do the following in a terminal:



sudo mv intrin-impl.h /usr/share/mingw-w64/include/psdk_inc/





3. GDI+ headers



Download GDI+ headers at: http://www.fon.hum.uva.nl/praat/GdiPlus_headers.zip . Unpack them, for example with Xarchiver via PCManFM (other any other filemanager). This will create a new folder which contains the header files. Open a terminal, enter this folder and copy the header files to the include folder:



sudo cp * /usr/i686-w64-mingw32/include/

sudo cp * /usr/x86_64-w64-mingw32/include/



Enter the include folder:



cd /usr/i686-w64-mingw32/include/

cd /usr/x86_64-w64-mingw32/include/



Rename the header files as follows:



sudo cp GdiPlus.h gdiplus.h

sudo mv GdiPlusimageAttributes.h GdiPlusImageAttributes.h

sudo mv GdiPlusMetaFile.h GdiPlusMetafile.h

sudo mv GdiPlusEnums.h GdiplusEnums.h

sudo mv GdiPlusFontCollection.h GdiplusFontCollection.h

sudo mv GdiPlusBase.h GdiplusBase.h

sudo mv GdiPlusTypes.h GdiplusTypes.h

sudo mv GdiPlusInit.h GdiplusInit.h

sudo mv GdiPlusMetafile.h GdiplusMetafile.h

sudo mv GdiPlusFont.h GdiplusFont.h

sudo mv GdiPlusBrush.h GdiplusBrush.h

sudo mv GdiPlusPen.h GdiplusPen.h

sudo mv GdiPlusColorMatrix.h GdiplusColorMatrix.h

sudo mv GdiPlusColor.h GdiplusColor.h

sudo mv GdiPlusFontFamily.h GdiplusFontFamily.h

sudo mv GdiPlusRegion.h GdiplusRegion.h

sudo mv GdiPlusHeaders.h GdiplusHeaders.h

sudo mv GdiPlusCachedBitmap.h GdiplusCachedBitmap.h

sudo mv GdiPlusImageCodec.h GdiplusImageCodec.h

sudo mv GdiPlusGpStubs.h GdiplusGpStubs.h

sudo mv GdiPlusLineCaps.h GdiplusLineCaps.h

sudo mv GdiPlusMetaHeader.h GdiplusMetaHeader.h

sudo mv GdiPlusImaging.h GdiplusImaging.h

sudo mv GdiPlusPixelFormats.h GdiplusPixelFormats.h

sudo mv GdiPlusStringFormat.h GdiplusStringFormat.h

sudo mv GdiPlusMem.h GdiplusMem.h

sudo mv GdiPlusMatrix.h GdiplusMatrix.h

sudo mv GdiPlusImageAttributes.h GdiplusImageAttributes.h

sudo mv GdiPlusPath.h GdiplusPath.h

sudo mv GdiPlusFlat.h GdiplusFlat.h

sudo mv GdiPlusBitmap.h GdiplusBitmap.h

sudo mv GdiPlusGraphics.h GdiplusGraphics.h

sudo mv shlobj.h Shlobj.h



4. GDI+ library



Download GDI+ library at: (32 bit) http://www.fon.hum.uva.nl/praat/libgdiplus.a-32.zip . Unpack the file. You will obtain the file libgdiplus.a. Copy this file to the lib folder:



sudo cp libgdiplus.a /usr/i686-w64-mingw32/lib/

sudo cp libgdiplus.a /usr/x86_64-w64-mingw32/lib/



5. Download Praat source



Go to: http://www.fon.hum.uva.nl/praat/download_sources.html. Download praat5414_sources.tar.gz, and unpack this.



6. Download makefile.defs.mingw32



Download makefile.defs.mingw-w64-32bit or makefile.defs.mingw-w64-64bit and store it in the sources directory (i.e. where makefile is). Rename the file in makefile.defs:



mv makefile.defs.mingw-w64-32bit makefile.defs

mv makefile.defs.mingw-w64-64bit makefile.defs



7. Compile the source code



Go to the sources directory and type:



make



The compilation process make take some time. When it is finished you will find a file Praat.exe.



8. Download libwinpthread-1.dll



Goto: http://www.dllme.com/dll/files/libwinpthread_1_dll.html and download libwinpthread-1.dll in the folder where Praat.exe is found.



Alternatively, you can copy .dll file to your c:/windows/system32/ folder. If this file already exists, create a backup before replacing. The computer needs to be rebooted before the file has any effect (but when using Wine under Linux a reboot is not necessary).



9. Run the Praat program



In Linux type:



wine Praat.exe



In Windows XP , 7 open a file manager and double click on:



Praat.exe