diff --git a/cinelerra-5.1/blds/cygwin.bld b/cinelerra-5.1/blds/cygwin.bld
index 270c42ca..43438eee 100755
--- a/cinelerra-5.1/blds/cygwin.bld
+++ b/cinelerra-5.1/blds/cygwin.bld
@@ -6,6 +6,6 @@
     --without-video4linux2 --without-xxf86vm --without-ladspa-build \
     --without-libzmpeg --without-commercial --without-thirdparty \
     --without-vaapi --without-vdpau --without-shuttle \
-    --without-x10tv --without-wintv --without-ladspa
+    --without-x10tv --without-wintv --without-libdpx --without-ladspa --without-openexr
   make
   make install ) 2>&1 | tee log
diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile
index 1cb58d50..f17983b9 100644
--- a/cinelerra-5.1/cinelerra/Makefile
+++ b/cinelerra-5.1/cinelerra/Makefile
@@ -444,6 +444,14 @@ ifneq (, $(filter $(PLATFORM), FreeBSD))
 LIBS += -lintl -liconv
 LIBS += -lexecinfo
 endif
+LIBS += -L$(FF_PATH)/lib
+LIBS += -Wl,--out-implib,x86_64/libcin.exe.a
+LIBS += -Wl,-rpath-link=:$(FF_PATH)/lib -Wl,--as-needed -Wl,--warn-common
+LIBS += -lavdevice -lavfilter -lavformat -lavcodec
+LIBS += -lswresample -lswscale -lavutil
+LIBS += -L/usr/lib -lintl -liconv
+LIBS += -lsecur32 -lole32 -luser32 -luser32 -lbcrypt -lshell32 -lstrmiids
+
 LIBS += `pkg-config --libs OpenEXR 2>/dev/null`
 LIBS += `pkg-config --libs flac 2>/dev/null`
 LIBS += `pkg-config --libs libjpeg 2>/dev/null`
@@ -526,7 +534,7 @@ CFLAGS += -DUSE_ALPHA
 
 else
 
-LDFLAGS1 = -Wl,-export-dynamic -g -Wl,-z,noexecstack
+LDFLAGS1 = -Wl,-export-all-symbols -g 
 LDFLAGS2 = $(LDFLAGS)
 LINKER = $(CXX) -o $(OUTPUT)
 
@@ -544,8 +552,8 @@ all:	$(OUTPUT) $(CUTADS) $(BDWRITE) $(LV2UI)
 $(OUTPUT): $(OBJS) $(THEME_DATA) $(DCRAW) $(LIBRARIES)
 	$(LINKER) `cat $(OBJDIR)/objs`
 	$(if $(findstring -g,$(CFLAGS)),objcopy --only-keep-debug $(OUTPUT) $(OUTPUT_G))
-	$(if $(findstring -g,$(CFLAGS)),objcopy --add-gnu-debuglink=$(OUTPUT_G) $(OUTPUT))
-	$(if $(findstring -ggdb,$(CFLAGS)),,strip $(OUTPUT))
+	#$(if $(findstring -g,$(CFLAGS)),objcopy --add-gnu-debuglink=$(OUTPUT_G) $(OUTPUT))
+	#$(if $(findstring -ggdb,$(CFLAGS)),,strip $(OUTPUT))
 	ln -f -s ../bin/$(WANT_CIN) ci
 
 ifneq ($(WANT_COMMERCIAL),no)
@@ -554,7 +562,7 @@ $(CUTADS):	$(CUTOBJS) $(CUTLIBS) $(LIBRARIES)
 	@$(CXX) $(CFLAGS) -pthread -o $@ $(CUTOBJS) $(CUTLIBS) $(LIBS)
 	$(if $(findstring -g,$(CFLAGS)),objcopy --only-keep-debug $(CUTADS) $(CUTADS).debuginfo)
 	$(if $(findstring -g,$(CFLAGS)),objcopy --add-gnu-debuglink=$(CUTADS).debuginfo $(CUTADS))
-	$(if $(findstring -ggdb,$(CFLAGS)),,strip $(CUTADS))
+	#$(if $(findstring -ggdb,$(CFLAGS)),,strip $(CUTADS))
 
 install-cutads:
 	cp -av $(OBJDIR)/cutads $(BINDIR)/.
@@ -566,7 +574,7 @@ $(BDWRITE):	$(BDWOBJS) $(LIBRARIES)
 	@echo $(CXX) -o $@ $(BDWOBJS)
 	@$(CXX) $(CFLAGS) -pthread -o $@ $(BDWOBJS) $(LIBS)
 	$(if $(findstring -g,$(CFLAGS)),objcopy --only-keep-debug $(BDWRITE) $(BDWRITE).debuginfo)
-	$(if $(findstring -ggdb,$(CFLAGS)),,strip $(BDWRITE))
+	#$(if $(findstring -ggdb,$(CFLAGS)),,strip $(BDWRITE))
 
 install-bdwrite:
 	cp -av $(OBJDIR)/bdwrite $(BINDIR)/.
@@ -611,7 +619,7 @@ $(OBJDIR)/lv2ui: $(LV2OBJS)
 	@echo $(CXX) \`cat $(OBJDIR)/c_flags\` $^ -o $@
 	@$(CXX) `cat $(OBJDIR)/c_flags` $^ -o $@ $(LIBS) $(LV2_LIBS) $(GTK2_LIBS)
 	$(if $(findstring -g,$(CFLAGS)),objcopy --only-keep-debug $(LV2UI) $(LV2UI).debuginfo)
-	$(if $(findstring -ggdb,$(CFLAGS)),,strip $(LV2UI))
+	#$(if $(findstring -ggdb,$(CFLAGS)),,strip $(LV2UI))
 
 .PHONY:	lv2ui
 lv2ui:	$(LV2UI)
diff --git a/cinelerra-5.1/cinelerra/TESTS b/cinelerra-5.1/cinelerra/TESTS
deleted file mode 100644
index 907d56cd..00000000
--- a/cinelerra-5.1/cinelerra/TESTS
+++ /dev/null
@@ -1,68 +0,0 @@
-Test 8, 16, 24 bit X server.
-Single frame record.
-Audio transition.
-Change channels.
-Chromakey
-Drag assets onto timeline.
-Pan photo.
-Zoom.
-Render all combinations of audio and video.
-Pan automation for audio.
-Frame reverse from end of timeline.
-Drag control points in camera and projector automation.
-Non realtime and realtime effects through the render effect menu.
-Copy and paste between Cinelerra sessions.
-Cut and paste multiple tracks.
-Paste assets while building indexes.
-Tweek plugin while playing back.
-Show and hide plugin while playing back.
-MJPEG recording with kernel driver
-Number of open file descriptors matches reality.
-Nudge audio and video.
-Change number of tracks shared by a plugin on the fly.
-Pan automation
-Fade automation
-Overlay tracks of different sizes
-Test pull console with LAD.
-
-
-
-Background render:
-play with effect
-detach effect and play
-turn effect off and play
-quit during playback
-
-
-
-
-Batch render:
-Batch render with and without labels.
-Batch render with renderfarm and labels.
-Stop batch render.
-Cancel batch render.
-
-Batch record:
-record several batches 1 minute apart.
-
-
-
-XMovie:
-Load DVD
-
-
-Load all tests in tests directory in succession.
-
-track_bounce2.xml - should output monaural audio on both speakers.
-
-
-
-
-Motion tracking:
-
-Make 10 frames of a text bitmap with quarter pixel offsets in each frame.
-Test global tracking modes.
-Make 10 frames with quarter degree rotation in each frame.
-Test rotation tracking modes.
-Test long range global tracking to see if the block follows the motion.
-
diff --git a/cinelerra-5.1/cinelerra/ci b/cinelerra-5.1/cinelerra/ci
index bc987833..22858982 120000
--- a/cinelerra-5.1/cinelerra/ci
+++ b/cinelerra-5.1/cinelerra/ci
@@ -1 +1 @@
-../bin/cinelerra
\ No newline at end of file
+../bin/cin
\ No newline at end of file
diff --git a/cinelerra-5.1/cinelerra/exportedl.C b/cinelerra-5.1/cinelerra/exportedl.C
index 69174635..666dfcf9 100644
--- a/cinelerra-5.1/cinelerra/exportedl.C
+++ b/cinelerra-5.1/cinelerra/exportedl.C
@@ -39,7 +39,7 @@
 #include "exportedl.h"
 #include "tracks.h"
 #include "transition.h"
-#if defined (__FreeBSD__) || defined (__NetBSD__)
+#if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__CYGWIN__)
 #include <libgen.h>
 #endif
 #include <ctype.h>
diff --git a/cinelerra-5.1/db/tdb.h b/cinelerra-5.1/db/tdb.h
index b746b640..f2c201f3 100644
--- a/cinelerra-5.1/db/tdb.h
+++ b/cinelerra-5.1/db/tdb.h
@@ -34,7 +34,7 @@ inline void operator delete[](void *t,size_t n) { free(t); }
 #endif
 
 #define ZMEDIA
-#define ZFUTEX
+//#define ZFUTEX
 #ifdef ZFUTEX
 #include <unistd.h>
 #include <endian.h>
diff --git a/cinelerra-5.1/guicast/bcsignals.C b/cinelerra-5.1/guicast/bcsignals.C
index 858ba409..5750c729 100644
--- a/cinelerra-5.1/guicast/bcsignals.C
+++ b/cinelerra-5.1/guicast/bcsignals.C
@@ -44,6 +44,7 @@
 #include <sys/prctl.h>
 #endif
 #include <sys/types.h>
+#include <sys/wait.h>
 
 BC_Signals* BC_Signals::global_signals = 0;
 static int signal_done = 0;
diff --git a/cinelerra-5.1/guicast/filesystem.h b/cinelerra-5.1/guicast/filesystem.h
index 90885554..28fc4a06 100644
--- a/cinelerra-5.1/guicast/filesystem.h
+++ b/cinelerra-5.1/guicast/filesystem.h
@@ -31,6 +31,9 @@
 #define readdir64 readdir
 #endif
 
+#define dirent64 dirent
+#define readdir64 readdir
+
 class FileItem
 {
 public:
diff --git a/cinelerra-5.1/libzmpeg3/y.C b/cinelerra-5.1/libzmpeg3/y.C
index c9ed1137..0646ed14 100644
--- a/cinelerra-5.1/libzmpeg3/y.C
+++ b/cinelerra-5.1/libzmpeg3/y.C
@@ -40,12 +40,11 @@ zmpeg3_t *ysrc;
 #endif
 
 
-//#define AUDIO
-#define VIDEO
-//#define LAST8M
+#define AUDIO
+//#define VIDEO
 static int verbose = 0;
 
-/* c++ `pkg-config --cflags --libs gtk+-2.0` y.C ./x86_64/libzmpeg3.a -lpthread -lasound -lm -lX11 */
+/* c++ `pkg-config --cflags --libs gtk+-2.0` y.C ./x86_64/libzmpeg3.a -lpthread -lasound -lm */
 
 #ifdef AUDIO
 snd_pcm_t *zpcm = 0;
@@ -93,7 +92,7 @@ void alsa_open(int chs,int rate)
   zpcm_total_samples = 0;
   zpcm_play_time = 0.;
   ret = snd_pcm_open(&zpcm, zpcm_device,
-     SND_PCM_STREAM_PLAYBACK, 0 /* + SND_PCM_NONBLOCK */);
+     SND_PCM_STREAM_PLAYBACK, 0 /* SND_PCM_NONBLOCK */);
   if( ret >= 0 )
     ret = snd_pcm_hw_params_any(zpcm, phw);
   if( ret >= 0 )
@@ -254,17 +253,6 @@ double alsa_time()
   return play_time;
 }
 
-#else
-
-double alsa_time()
-{
-  double time, play_time;
-  struct timeval tv;
-  gettimeofday(&tv,NULL);
-  time = tv.tv_sec + tv.tv_usec/1000000.0;
-  return time;
-}
-
 #endif
 
 int done = 0;
@@ -366,7 +354,7 @@ void *video_thread(void *the_zsrc)
   unsigned char **rows, **row0, **row1, *cap, *cap0, *cap1;
   int ret, row, frame, dropped, more_data;
   int width, height, owidth, oheight;
-  const int frame_drop = 0;
+  const int frame_drop = 1;
   zmpeg3_t *zsrc = (zmpeg3_t *)the_zsrc;
 
   frame_rate = mpeg3_frame_rate(zsrc, 0);
@@ -379,8 +367,8 @@ void *video_thread(void *the_zsrc)
   //owidth = 1680-64;
   //oheight = height;
   //owidth = width;
-  oheight = 540;
-  owidth = 960;
+  oheight = 720;
+  owidth = 1280;
 
   visual = gdk_visual_get_system();
   /* toplevel window */
@@ -430,7 +418,7 @@ void *video_thread(void *the_zsrc)
   while( done == 0 && more_data ) {
     if( !gtk_events_pending() ) {
       more_data = 0;
-      delay = (frame+dropped)/frame_rate - alsa_time();
+//      delay = (frame+dropped)/frame_rate - alsa_time();
 //      delay = the_time() - video_time(zsrc,0);
       if( frame_drop ) {
         if( -delay >= frame_delay ) {
@@ -440,8 +428,8 @@ void *video_thread(void *the_zsrc)
           dropped += nframes;
         }
       }
-      if( delay > 0 )
-        usleep((int)(delay*1000000.0));
+      //if( delay > 0 )
+      //  usleep((int)(delay*1000000.0));
       ret = mpeg3_read_frame(zsrc, rows, 0, 0, width, height,
                owidth, oheight, cmdl, 0);
       //printf("%d %ld\n",frame,zsrc->vtrack[0]->demuxer->titles[0]->fs->current_byte);
@@ -454,7 +442,6 @@ void *video_thread(void *the_zsrc)
       GdkGC *blk = image->style->black_gc;
       gdk_draw_rgb_image(image->window,blk, 0,0,owidth,oheight,
          GDK_RGB_DITHER_NONE,cap,owidth*BPP);
-      gdk_flush();
 #if 0
 #if 0
       { static FILE *fp = 0;
@@ -536,9 +523,8 @@ void *audio_thread(void *the_zsrc)
 
     alsa_write(n);
     delay = audio_time(zsrc,stream) - the_time();
-    if( (delay-=ahead) > 0. ) {
+    if( (delay-ahead) > 0. )
       usleep((int)(delay*1000000.0/2.));
-    }
     more_data |= !mpeg3_end_of_audio(zsrc,0);
   }
 
@@ -552,8 +538,6 @@ void *audio_thread(void *the_zsrc)
 int main(int ac, char **av)
 {
   int ret;
-  struct stat st_buf;
-  long pos;
   setbuf(stdout,NULL);
   tstart = -1.;
 
@@ -570,7 +554,6 @@ int main(int ac, char **av)
   //zmpeg3_t* zsrc = mpeg3_open("/dvd/VIDEO_TS/VTS_01_0.IFO",&ret);
   //zmpeg3_t* zsrc = mpeg3_open("/home/dat2.vts",&ret);
   //zmpeg3_t* zsrc = mpeg3_open("/dvd/BDMV/STREAM/00000.m2ts",&ret);
-  //zmpeg3_t* zsrc = mpeg3_open("/root/xcolorbars1.mpg",&ret);
   zmpeg3_t* zsrc = mpeg3_open(av[1],&ret);
   ysrc = zsrc;
   printf(" ret = %d\n",ret);
@@ -586,15 +569,8 @@ int main(int ac, char **av)
 #endif
 
   mpeg3_set_cpus(zsrc,3);
-  pos = 0;
-#ifdef LAST8M
-  if( stat(zsrc->fs->path, &st_buf) >= 0 ) {
-    if( (pos = (st_buf.st_size & ~0x7ffl) - 0x800000l) < 0 )
-      pos = 0;
-  }
-#endif
-  mpeg3_seek_byte(zsrc, pos);
-  mpeg3_show_subtitle(zsrc, 0, 0);
+  mpeg3_seek_byte(zsrc,0);
+  mpeg3_show_subtitle(zsrc, 0);
   signal(SIGINT,sigint);
 
 #ifdef AUDIO
diff --git a/cinelerra-5.1/plugin_config b/cinelerra-5.1/plugin_config
index 56f43511..ecd58377 100644
--- a/cinelerra-5.1/plugin_config
+++ b/cinelerra-5.1/plugin_config
@@ -4,12 +4,21 @@ CFLAGS += -I../ -I$(CINELERRA) -I$(GUICAST) -I../colors -fPIC
 CFLAGS += $(static_incs)
 LFLAGS += $(static_libs)
 LFLAGS += $(LDFLAGS)
+
+LFLAGS +=  -Wl,$(CINELERRA)/$(OBJDIR)/libcin.exe.a
+LFLAGS += -lintl -liconv
+ifneq ($(WANT_GL),no)
+LFLAGS += -lGL -lGLU
+endif
+
 LDLINKER ?= $(CXX) -shared
 $(shell mkdir -p $(OBJDIR))
 
+#SFX=plugin
+SFX=dll
 PLUGIN_DIR := $(BINDIR)/plugins
 OUTPUT_DIR = $(PLUGIN_DIR)/$($(PLUGIN))
-OUTPUT = $(OUTPUT_DIR)/$(PLUGIN).plugin
+OUTPUT = $(OUTPUT_DIR)/$(PLUGIN).$(SFX)
 OUTPUT_G = $(OBJDIR)/$(PLUGIN).debuginfo
 
 $(shell echo $(CFLAGS) > $(OBJDIR)/c_flags)
@@ -20,16 +29,16 @@ ifeq ($(OUTPUT_THEME),)
 $(OUTPUT): $(OBJS) $(OUTPUT_DIR) $(OUTPUT_BINS)
 	$(LDLINKER) -o $(OUTPUT) $(OBJS) $(OUTPUT_BINS) `cat $(OBJDIR)/l_flags`
 	$(if $(findstring -g,$(CFLAGS)),objcopy --only-keep-debug $(OUTPUT) $(OUTPUT_G))
-	$(if $(findstring -ggdb,$(CFLAGS)),,strip $(OUTPUT))
+	#$(if $(findstring -ggdb,$(CFLAGS)),,strip $(OUTPUT))
 
 else
 
 THEME_DATA = $(OBJDIR)/$(PLUGIN)_data.o
 
 $(OUTPUT_THEME): $(OBJS) $(OUTPUT_DIR) $(THEME_DATA)
-	$(LDLINKER) -o $(OUTPUT_THEME) $(OBJS) $(THEME_DATA) $(LDFLAGS)
+	$(LDLINKER) -o $(OUTPUT_THEME) $(OBJS) $(THEME_DATA) `cat $(OBJDIR)/l_flags`
 	$(if $(findstring -g,$(CFLAGS)),objcopy --only-keep-debug $(OUTPUT_THEME) $(OUTPUT_G))
-	$(if $(findstring -ggdb,$(CFLAGS)),,strip $(OUTPUT_THEME))
+	#$(if $(findstring -ggdb,$(CFLAGS)),,strip $(OUTPUT_THEME))
 
 $(THEME_DATA):
 	cd $(OBJDIR) && \
