GNOME Bugzilla – Bug 572993
[subparse] broken libregex dependency on Windows
Last modified: 2009-03-03 09:21:38 UTC
I'm trying to build plugins-base (with enabled subparse) on Windows with MinGW/MSys. It requires reg* functions (declared in regex.h). I found necessary package (with import library, shared library and header) at http://sourceforge.net/project/showfiles.php?group_id=7382&package_id=12650 Configure picks up regex.h and subsequently enables subparse, however it never passes -lregex to the linker (and i can't find a place where it should do that, it seems that configure script is not supposed to do that at all), as a result subparse fails to build: libtool: link: gcc -shared .libs/libgstsubparse.dll.def .libs/libgstsubparse_la-gstssaparse.o .libs/libgstsubparse_la-gstsubparse.o .libs/libgstsubparse_la-samiparse.o .libs/libgstsubparse_la-tmplayerparse.o .libs/libgstsubparse_la-mpl2parse.o -LD:/msys/local/lib -L/usr/local/lib -L/d/python26/Lib /usr/local/lib/libgstbase-0.10.dll.a /usr/local/lib/libgstreamer-0.10.dll.a -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 /usr/local/lib/libxml2.dll.a -ldl -lpthread -lws2_32 -lglib-2.0 /usr/local/lib/libintl.dll.a /usr/local/lib/libiconv.dll.a -mms-bitfields -mms-bitfields -o .libs/libgstsubparse.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libgstsubparse.dll.a Info: resolving ___gst_debug_min by linking to __imp____gst_debug_min (auto-import) Creating library file: .libs/libgstsubparse.dll.a d:/mingw/bin/../lib/gcc/mingw32/4.3.0/../../../../mingw32/bin/ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line. This should work unless it involves constant data structures referencing symbols from auto-imported DLLs. .libs/libgstsubparse_la-gstsubparse.o: In function `gst_sub_parse_data_format_autodetect': d:\projects\gst-plugins-base\gst\subparse/gstsubparse.c:1003: undefined reference to `regexec' d:\projects\gst-plugins-base\gst\subparse/gstsubparse.c:1007: undefined reference to `regexec' d:\projects\gst-plugins-base\gst\subparse/gstsubparse.c:992: undefined reference to `regcomp' d:\projects\gst-plugins-base\gst\subparse/gstsubparse.c:992: undefined reference to `regcomp' d:\projects\gst-plugins-base\gst\subparse/gstsubparse.c:998: undefined reference to `regerror' configuring with LDFLAGS="-L/local/lib" and LIBS="-lregex" fixes the problem. Alternatively you may want to rewrite subparse to use GLib for regular expressions.
Created attachment 129704 [details] [review] Use GLib regex functions instead of regex.h Only tested on .srt files.
Only the return value of g_regex_new() needs to be tested for NULL: - if (mdvd_grx == NULL || gerr != NULL) { + if (mdvd_grx == NULL) { The GST_WARNINGs should be g_warning()s. As a side note, the creation of regexes here is not thread-safe, but it is unsafe without the patch too. I'd like to see this code fixed to use GOnce. If you want to fix it, go ahead, otherwise just mark it /* FIXME thread unsafe, should use GOnce */.
The best would probably be to initialize the regex in class_init or plugin_init and have them as static global variables IMHO. Apart from that this patch needs #if GLIB_CHECK_VERSION(2,16,0) around the GRegex stuff and the old stuff in the #else part until we can depend on GLib 2.16.0 or newer... which is soon I hope :)
Created attachment 129723 [details] [review] Use GLib regex functions instead of rege.h; Use GOnce to init regexps Didn't tested at all.
Created attachment 129728 [details] [review] Use GLib regex functions instead of regex.h when glib 2.16 is available; Use GOnce to init regexps (for both regex.h and glib);
Created attachment 129729 [details] [review] Use GLib regex functions instead of regex.h when glib 2.16 is available; Use GOnce to init regexps (for both regex.h and glib); Forgot to #include <regex.h> Obviously, didn't tested the pre-glib-2.16 variant.
Created attachment 129731 [details] [review] Use GLib regex functions instead of regex.h when glib 2.16 is available; Use GOnce to init regexps (for both regex.h and glib); This one builds with both GLib < 2.14 and GLib >= 2.14.
David, are you going to commit this? Looks good to me except that GRegex was actually available since 2.14, not 2.16 :)
As discussed on IRC, we shouldn't be committing this - patches not attributable to a real person aren't acceptable. "LRN" refuses to provide this information, so though his/her bug reports are still valuable, the patches aren't usable.
Name's Руслан Ижбулатов. Now go and submit that patch already!
commit db596d27a29309eff2d7060405998bd6a68bfc31 Author: LRN <lrn1986@gmail.com> Date: Sat Feb 28 15:23:20 2009 -0800 subparse: Convert regex code to GRegex code Fixes: #572993. Patch author prefers to use an alias, contact ds if you actually need a real name. Signed-off-by: David Schleef <ds@schleef.org>