Hi all,

Recently I've had to compile Praat with Mingw. I had to make a few
source code changes to get this to work (for example, the
Melder_wcstok function not being consistently used, the Win32 API not
defining a function to POSIX standard, and a few new Makefile flags
needed).

As an information guide for anyone trying to compile Praat on Mingw,
here's what you need to do (or at least what I did in addition to the
code changes)

1. Install Mingw (obviously)
2. Get the DirectX headers
(http://mamedev.org/tools/20100102/directx-headers-for-mingw-20100102.zip),
and put them in your Mingw include directory
3. Get the Windows SDK, and copy Ks.h and Ksmedia.h from it into your
Mingw include directory (for some reason the Mingw ones are broken)
4. Put makefiles/makefile.defs.mingw in makefile.defs in your Windows 32
5. Copy audio/Makefile.mingw to audio/Makefile (this is to compile the
Windows version of the libraries)

You should now be able to compile Praat in Mingw from the command
prompt using mingw32-make.

The patch is included below.

Regards,

Chris Northwood,
MSc Computer Science with Speech & Language Processing,
Department of Computer Science,
The University of Sheffield.

diff -urN sources_5131_old/audio/FLAC/flac_share_alloc.h 
sources_5131/audio/FLAC/flac_share_alloc.h
--- sources_5131_old/audio/FLAC/flac_share_alloc.h      Tue Nov 20 17:30:52 2007
+++ sources_5131/audio/FLAC/flac_share_alloc.h  Wed Apr 28 22:35:05 2010
@@ -28,7 +28,7 @@
  */
 
 #include <limits.h> /* for SIZE_MAX */
-#if !defined _MSC_VER && !defined __MINGW32__ && !defined __EMX__
+#if !defined _MSC_VER && !defined __EMX__
 #include <stdint.h> /* for SIZE_MAX in case limits.h didn't get it */
 #endif
 #include <stdlib.h> /* for size_t, malloc(), etc */
diff -urN sources_5131_old/audio/Makefile.mingw 
sources_5131/audio/Makefile.mingw
--- sources_5131_old/audio/Makefile.mingw       Thu Jan  1 00:00:00 1970
+++ sources_5131/audio/Makefile.mingw   Wed Apr 28 22:36:31 2010
@@ -0,0 +1,25 @@
+# Makefile of the library "audio"
+# Paul Boersma, 22 February 2010
+
+include ../makefile.defs
+
+OBJECTS = pa_win_wmme.o pa_win_util.o pa_win_hostapis.o pa_win_waveformat.o 
pa_win_ds.o pa_win_ds_dynlink.o pa_win_wdmks.o pa_skeleton.o \
+       pa_front.o pa_unix_util.o pa_debugprint.o pa_cpuload.o \
+       pa_allocation.o pa_process.o pa_converters.o pa_dither.o \
+       pa_stream.o
+
+.PHONY: all clean
+
+all: libaudio.a
+
+clean:
+       $(RM) $(OBJECTS)
+       $(RM) libaudio.a
+
+libaudio.a: $(OBJECTS)
+       touch libaudio.a
+       rm libaudio.a
+       ar cq libaudio.a $(OBJECTS)
+       $(RANLIB) libaudio.a
+
+$(OBJECTS): *.h
diff -urN sources_5131_old/dwsys/NUM2.c sources_5131/dwsys/NUM2.c
--- sources_5131_old/dwsys/NUM2.c       Thu Mar 11 13:45:14 2010
+++ sources_5131/dwsys/NUM2.c   Wed Apr 28 22:34:10 2010
@@ -127,7 +127,7 @@
        if (((dup = Melder_wcsdup (s)) == NULL) ||
                ((numbers = NUMdvector (1, capacity)) == NULL)) goto end;
        wchar_t *last;
-       token = wcstok (dup, delimiter, & last);
+       token = Melder_wcstok (dup, delimiter, & last);
        while (token)
        {
                double value = wcstod (token, NULL);
@@ -138,7 +138,7 @@
                        numbers = new; capacity = newsize;
                }
                numbers[++n] = value;
-               token = wcstok (NULL, delimiter, & last);
+               token = Melder_wcstok (NULL, delimiter, & last);
        }
 end:
        *numbers_found = n;
diff -urN sources_5131_old/makefiles/makefile.defs.mingw 
sources_5131/makefiles/makefile.defs.mingw
--- sources_5131_old/makefiles/makefile.defs.mingw      Tue Mar 20 21:47:00 2007
+++ sources_5131/makefiles/makefile.defs.mingw  Wed Apr 28 22:30:37 2010
@@ -5,7 +5,7 @@
 
 CC = mingw32-gcc -D_WIN32 -DMINGW -std=gnu99 -DDONT_INCLUDE_QUICKTIME 
-Dmain=wingwmain -mwindows -O2
 
-LIBS = -lwinmm -lwsock32 -lcomctl32
+LIBS = -lwinmm -lwsock32 -lcomctl32 -lole32 -lsetupapi
 
 RANLIB = ls
 ICON = praat_win.o
diff -urN sources_5131_old/sys/melder.h sources_5131/sys/melder.h
--- sources_5131_old/sys/melder.h       Mon Mar  8 22:54:36 2010
+++ sources_5131/sys/melder.h   Wed Apr 28 22:32:31 2010
@@ -53,6 +53,10 @@
        #define NULL  ((void *) 0)
 #endif
 
+#ifdef MINGW
+#   define swprintf   _snwprintf
+#endif
+
 /********** NUMBER TO STRING CONVERSION **********/
 
 /*

Reply via email to