Skip to contentSkip to conversation

MinGW compatibility patches

PATCH In review Руслан Ижбулатов 2 participants 10 messages Apr 9, 2019 – Apr 25, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover MinGW compatibility patches

Here's a few patches that might be useful.

Руслан Ижбулатов (8):
Include windows.h for vfw
Specify correct path to barcode.png
Check for clock_gettime on pthread library as well Disable zbarcam-gtk on Windows
Use -no-undefined for libzbargtk
Make zbargtk build on Windows
Make use of glib thread names
Correctly generate version.xml and reldate.xml

 Makefile.am             |  2 +-
 configure.ac            |  8 ++++----
 gtk/Makefile.am.inc     |  2 +-
 gtk/zbargtk.c           | 12 +++++++++++-
 zbarcam/Makefile.am.inc |  2 ++
 5 files changed, 19 insertions(+), 7 deletions(-)
Signature · 1 line
2.4.0
#1 lore raw

PATCH 1/8 Include windows.h for vfw

vfw.h can't be included without windows.h to supply basic type definitions.

---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure.ac +1 -1
index 58b97ec..6e092e0 100644
@@ -257,7 +257,7 @@ configure --disable-video to skip building video support.])],
         )],
   [AC_CHECK_HEADERS([vfw.h], [with_video="vfw"],
     [AC_MSG_FAILURE([test for VfW video support failed!
-configure --disable-video to skip building video support.])])])
+configure --disable-video to skip building video support.])],[#include <windows.h>])])
 
 AS_IF([test "x$have_libv4l" = "xyes"],
    [PKG_CHECK_MODULES([V4L2], [libv4l2], [],
Signature · 1 line
2.4.0
#2 lore raw

PATCH 2/8 Specify correct path to barcode.png

In reply to Руслан Ижбулатов

$(srcdir)/examples/barcode.png does not exist anymore.

---
 Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile.am +1 -1
index c767d15..a9367b3 100644
@@ -73,7 +73,7 @@ EXTRA_DIST += perl/MANIFEST perl/README perl/Changes perl/COPYING.LIB \
 
 if WIN32
 dist_doc_DATA += README.windows
-pkgdata_DATA = $(srcdir)/examples/barcode.png \
+pkgdata_DATA = $(srcdir)/python/test/barcode.png \
     $(srcdir)/examples/scan_image.cpp $(srcdir)/examples/scan_image.vcproj
 
 %-rc.o: %.rc
Signature · 1 line
2.4.0
#3 lore raw

PATCH 3/8 Check for clock_gettime on pthread library as well

In reply to Руслан Ижбулатов

On Windows that function might be in libpthread.

---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure.ac +1 -1
index 6e092e0..3224888 100644
@@ -183,7 +183,7 @@ ZBAR_CHK_CODE([pdf417], [PDF417 symbology (incomplete)])
 
 dnl libraries
 
-AC_SEARCH_LIBS([clock_gettime], [rt])
+AC_SEARCH_LIBS([clock_gettime], [rt pthread])
 AM_ICONV()
 
 dnl libraries linkage
Signature · 1 line
2.4.0
#4 lore raw

PATCH 4/8 Disable zbarcam-gtk on Windows

In reply to Руслан Ижбулатов

It requires scan_video.c, which includes linux/videodev2.h, so the code is clearly not meant to be built for Windows, even if GTK is available there.

---
 zbarcam/Makefile.am.inc | 2 ++
 1 file changed, 2 insertions(+)
zbarcam/Makefile.am.inc +2 -0
index b112783..ad16d3c 100644
@@ -5,12 +5,14 @@ zbarcam_zbarcam_LDADD = zbar/libzbar.la
 CLEANFILES += zbarcam/.libs/zbarcam zbarcam/moc_zbarcam_qt.h
 
 if HAVE_GTK
+if !WIN32
 bin_PROGRAMS += zbarcam/zbarcam-gtk
 zbarcam_zbarcam_gtk_SOURCES = zbarcam/zbarcam-gtk.c zbarcam/scan_video.c
 zbarcam_zbarcam_gtk_CPPFLAGS = $(GTK_CFLAGS) $(AM_CPPFLAGS)
 zbarcam_zbarcam_gtk_LDADD = $(GTK_LIBS) gtk/libzbargtk.la zbar/libzbar.la \
 	$(AM_LDADD)
 endif
+endif
 
 if HAVE_QT
 bin_PROGRAMS += zbarcam/zbarcam-qt
Signature · 1 line
2.4.0
#5 lore raw

PATCH 5/8 Use -no-undefined for libzbargtk

In reply to Руслан Ижбулатов

-no-undefined is required to build shlibs on Windows. Doesn't hurt on other platforms either (unless a shlib is built with undefined symbols by design, which is not the case here).

---
 gtk/Makefile.am.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
gtk/Makefile.am.inc +1 -1
index 406fd86..f7e8e6c 100644
@@ -1,7 +1,7 @@
 lib_LTLIBRARIES += gtk/libzbargtk.la
 gtk_libzbargtk_la_CPPFLAGS = -Igtk $(GTK_CFLAGS) $(AM_CPPFLAGS)
 gtk_libzbargtk_la_LDFLAGS = -version-info $(ZGTK_LIB_VERSION) \
-    -export-symbols-regex "^zbar_gtk_.*" $(AM_LDFLAGS)
+    -export-symbols-regex "^zbar_gtk_.*" $(AM_LDFLAGS) -no-undefined
 gtk_libzbargtk_la_LIBADD = $(GTK_LIBS) zbar/libzbar.la $(AM_LIBADD)
 
 dist_gtk_libzbargtk_la_SOURCES = gtk/zbargtk.c gtk/zbargtkprivate.h
Signature · 1 line
2.4.0
#6 lore raw

PATCH 6/8 Make zbargtk build on Windows

In reply to Руслан Ижбулатов

The code is mostly platform-agnostic, except for this small part that is written for X. Add ifdefs with an appropriate W32 header, and call zbar_window_attach() with correct W32 arguments. Use HAVE_X as a condition.

---
 gtk/zbargtk.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
gtk/zbargtk.c +10 -0
index c7e05e3..595acfe 100644
@@ -22,7 +22,11 @@
  *------------------------------------------------------------------------*/
 
 #include <gtk/gtksignal.h>
+#ifdef HAVE_X
 #include <gdk/gdkx.h>
+#elif defined(_WIN32)
+#include <gdk/gdkwin32.h>
+#endif
 
 #include <zbar/zbargtk.h>
 #include "zbargtkprivate.h"
@@ -380,9 +384,15 @@ static void zbar_gtk_realize (GtkWidget *widget)
     gdk_window_set_back_pixmap(widget->window, NULL, TRUE);
 
     /* attach zbar_window to underlying X window */
+#ifdef HAVE_X
     if(zbar_window_attach(zbar->window,
                            gdk_x11_drawable_get_xdisplay(widget->window),
                            gdk_x11_drawable_get_xid(widget->window)))
+#elif defined(_WIN32)
+    if(zbar_window_attach(zbar->window,
+                           GDK_WINDOW_HWND (widget->window),
+                           0))
+#endif
         zbar_window_error_spew(zbar->window, 0);
 }
 
Signature · 1 line
2.4.0
#7 lore raw

PATCH 7/8 Make use of glib thread names

In reply to Руслан Ижбулатов

This is optional, but why not use it?

---
 gtk/zbargtk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
gtk/zbargtk.c +1 -1
index 595acfe..c16f05c 100644
@@ -637,7 +637,7 @@ static void zbar_gtk_init (ZBarGtk *self)
 
     /* spawn a thread to handle decoding and video */
     zbar->queue = g_async_queue_new();
-    zbar->thread = g_thread_new(NULL, zbar_gtk_processing_thread, self);
+    zbar->thread = g_thread_new("zbar gtk processing thread", zbar_gtk_processing_thread, self);
     g_assert(zbar->thread);
 }
 
Signature · 1 line
2.4.0
#8 lore raw

PATCH 8/8 Correctly generate version.xml and reldate.xml

In reply to Руслан Ижбулатов

The buildsystem expects these files to be in srcdir, so put them there. Otherwise documentation won't build (xmlto complains that it can't find the files. Note that it uses an absolute path, so there's no way to solve this with its --searchpath argument).

---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
configure.ac +2 -2
index 3224888..41d77fd 100644
@@ -667,14 +667,14 @@ AC_CONFIG_COMMANDS([doc/version.xml],
   [AS_IF([test -f doc/version.xml && \
           ! echo $VERSION | diff doc/version.xml - >/dev/null 2>&1 || \
           ! echo $VERSION | diff $srcdir/doc/version.xml - >/dev/null 2>&1 ],
-    [echo "writing new doc/version.xml" ; echo $VERSION > doc/version.xml ])],
+    [echo "writing new doc/version.xml" ; echo $VERSION > $srcdir/doc/version.xml ])],
   [VERSION="$VERSION"]
 )
 AC_CONFIG_COMMANDS([doc/reldate.xml],
   [AS_IF([test -f doc/reldate.xml && \
           ! echo $RELDATE | diff doc/reldate.xml - >/dev/null 2>&1 || \
           ! echo $RELDATE | diff $srcdir/doc/reldate.xml - >/dev/null 2>&1 ],
-    [echo "writing new doc/reldate.xml" ; echo $RELDATE > doc/reldate.xml ])],
+    [echo "writing new doc/reldate.xml" ; echo $RELDATE > $srcdir/doc/reldate.xml ])],
   [RELDATE="$RELDATE"]
 )
 
Signature · 1 line
2.4.0
#9 lore raw
In reply to Руслан Ижбулатов

Em Tue, 9 Apr 2019 12:38:34 +0000
Руслан Ижбулатов <[email protected]> escreveu:

Quoted 11 lines

Here's a few patches that might be useful.

Руслан Ижбулатов (8):
Include windows.h for vfw
Specify correct path to barcode.png
Check for clock_gettime on pthread library as well Disable zbarcam-gtk on Windows
Use -no-undefined for libzbargtk
Make zbargtk build on Windows
Make use of glib thread names
Correctly generate version.xml and reldate.xml

Thank you for the patches. Applied today, and launched a new ZBar version (0.22.1) with the build corrections.

Quoted 8 lines
 Makefile.am             |  2 +-
 configure.ac            |  8 ++++----
 gtk/Makefile.am.inc     |  2 +-
 gtk/zbargtk.c           | 12 +++++++++++-
 zbarcam/Makefile.am.inc |  2 ++
 5 files changed, 19 insertions(+), 7 deletions(-)

Thanks,
Mauro