Subject: | [Win32] compilation problems using mingw port of g++ |
Hi,
In order to build 1.61 on MS Windows, I applied this patch to TagLib.xs
########################
--- TagLib.xs_orig 2012-08-24 13:42:24 +1000
+++ TagLib.xs 2012-08-26 20:36:17 +1000
@@ -17,17 +17,30 @@
#include "iconv_wrap.h"
-#ifdef do_open(a,b,c,d,e,f,g)
-#undef do_open(a,b,c,d,e,f,g)
+#ifdef do_open
+/* #undef do_open(a,b,c,d,e,f,g) */
#undef do_open
-#undef do_close(a,b)
+/* #undef do_close(a,b) */
#undef do_close
#endif
+
+#ifdef __MINGW32__
+#ifdef read
+#undef read
+#endif
+#ifdef write
+#undef write
+#endif
+#ifdef setbuf
+#undef setbuf
+#endif
+#endif
+
#include "apeitem.h"
#ifndef do_open
-#define do_open Perl_do_open
+/* #define do_open Perl_do_open */
#define do_open(a,b,c,d,e,f,g) Perl_do_open(aTHX_ a,b,c,d,e,f,g)
-#define do_close Perl_do_close
+/* #define do_close Perl_do_close */
#define do_close(a,b) Perl_do_close(aTHX_ a,b)
#endif
############################
That should be portable - though that's untested.
The changes to the re-defining of do_open and do_close are probably not
necessary - I think they serve merely to quiet some warnings.
However the undeffing of read, write and setbuf are necessary.
There's another problem ... iconv_wrap.h assumes that the second arg to
libiconv's iconv function (in iconv.h) is 'char **', but sometimes it
can be 'const char **'. (I don't know what determines the
presence/absence of the 'const' qualifier - it's something that
configure determines during the building of libiconv.)
Whenn the 'const' qualifier is in place, I need to also apply the
following patch:
###########################
--- include/iconv_wrap.h_orig 2012-08-24 13:34:03 +1000
+++ include/iconv_wrap.h_new 2012-08-26 20:38:07 +1000
@@ -26,7 +26,7 @@
#else
size_t iconv_wrap(iconv_t cd,
- char **inbuf,
+ const char **inbuf,
size_t *inbytesleft,
char **outbuf,
size_t *outbytesleft)
--- xs/tstring.xs_orig 2012-08-25 17:36:48 +1000
+++ xs/tstring.xs_new 2012-08-25 17:52:56 +1000
@@ -18,7 +18,8 @@
enum TagLib::String::Type t;
bool is_copy_from_string = TRUE;
iconv_t codec;
- char *inbuf, *outbuf;
+ const char *inbuf;
+ char *outbuf;
size_t inlen, outlen, utf8len;
char *utf8;
char *errmsg;
@@ -324,7 +325,8 @@
PREINIT:
iconv_t codec;
char mb[8];
- char *inbuf, *outbuf;
+ const char *inbuf;
+ char *outbuf;
size_t inlen, outlen;
INIT:
outlen = 8;
--- xs/stringiterator.xs_orig 2012-08-25 17:53:38 +1000
+++ xs/stringiterator.xs_new 2012-08-25 17:54:52 +1000
@@ -53,7 +53,8 @@
iconv_t codec = iconv_open("UTF8", "WCHAR_T");
if(codec == (iconv_t)(-1))
croak("iconv_open failed");
- char *inbuf, *outbuf;
+ const char *inbuf;
+ char *outbuf;
char utf8[1024];
size_t inlen, outlen;
inlen = sizeof(wchar_t);
###########################
Otherwise the build croaks with the diagnostic:
error: invalid conversion from 'const char**' to 'char**'
(With gcc, I think that conversion merely triggers a warning - but g++
apparently considers it to be a fatal error.)
The annoying thing is that, if you apply that patch and the 'const'
qualifier is *not* present, then the build fails - so you need to know
which rendition of iconv() is to be found in iconv.h in order to know
whether that patch ought to be applied.
Anyway, with appropriate patches in place, Audio::TagLib then builds fine.
There are some test failures - TagLib_String.t and
TagLib_String_Iterator.t (on all perls that I tested) and additionally,
on *some* perls only, TagLib_ID3v2_FrameList.t.
I'll try to put together a bug report for those once I've had a chance
to take a bit of a look.
Cheers,
Rob