in reply to Net::LibIDN in Windows, is it possible?

And if I have to install it, will I have to install it on every Windows computer that runs a copy of my code?

If you build against a static libidn library, then the libidn functionality will be built into the Net::LibIDN binaries, and you won't have to distribute anything other than your build of Net::LibIDN. But if you build against a shared libidn library (dll) then you'll have to distribute the dll as well as your build of Net::LibIDN.

I find that libidn-1.12 builds fine as a static library (didn't test a shared build) using MinGW in the MSYS shell. Just run ./configure --disable-shared --enable-static LDFLAGS=-L/usr/local/lib CPPFLAGS=-I/usr/local/include followed by make && make check then make install. Note that libiconv, which can be built using the same mantra, is also required.

Here's a diff showing the hack I made to the Makefile.PL in order to build Net::LibIDN-0.11:
C:\>diff -u Makefile.PL_orig Makefile.PL --- Makefile.PL_orig Fri Feb 6 10:40:08 2009 +++ Makefile.PL Fri Feb 6 10:40:45 2009 @@ -46,18 +46,18 @@ "disable-tld" => \$disable_tld ); - if ($libdir) + if (1) { - $Params{LIBS} = "-L$libdir -lidn"; + $Params{LIBS} = "-LC:/_32/msys/1.0/local/lib -lidn -li +conv"; } else { $Params{LIBS} = '-lidn'; } - if ($incdir) + if (1) { - $Params{INC} = "-I$incdir"; + $Params{INC} = "-IC:/_32/msys/1.0/local/include"; } else { @@ -164,7 +164,7 @@ return 0; } - foreach my $cc (qw/cc gcc/) + foreach my $cc (qw/gcc/) { unlink($test); system "$cc $cflags -o $test $test.c $ldflags";
Unfortunately the tests fail with "Free to wrong pool..." errors, perhaps the result of bad practices used in the XS file. I'll see if I can patch the XS file so that the tests pass - and I'll post again to this thread when (if) I succeed.

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: Net::LibIDN in Windows, is it possible?
by syphilis (Archbishop) on Feb 06, 2009 at 01:00 UTC
    I'll see if I can patch the XS file so that the tests pass

    UPDATE: The correct patch to apply is at https://rt.cpan.org/Ticket/Attachment/564402/285045/LibIDN_xs.diff . See Re: [Win32] "Free to wrong pool ..." error.

    Not necessarily the right way to correct it. It may well lead to memory leaks, but at least it renders the module usable on Win32 (in that it enables all of the tests to pass without warning or error):
    C:\> diff -u LibIDN.xs_orig LibIDN.xs --- LibIDN.xs_orig Fri Feb 6 11:48:52 2009 +++ LibIDN.xs Fri Feb 6 11:53:00 2009 @@ -27,13 +27,13 @@ return NULL; res = stringprep_profile(utf8, &output, profile, 0); - free(utf8); + /* free(utf8); */ if( (res != STRINGPREP_OK) || !output) return NULL; res_str = stringprep_convert(output, charset, "UTF-8"); - free(output); + /* free(output); */ return res_str; } @@ -96,7 +96,7 @@ if (utf8_str) { res = idna_to_ascii_8z(utf8_str, &tmp_str, fla +gs); - free(utf8_str); + /* free(utf8_str); */ } else { @@ -110,8 +110,8 @@ OUTPUT: RETVAL CLEANUP: - if (tmp_str) - free(tmp_str); + if (tmp_str){} + /* free(tmp_str); */ char * @@ -133,7 +133,7 @@ if (tmp_str) { res_str = stringprep_convert(tmp_str, charset, + "UTF-8"); - free(tmp_str); + /* free(tmp_str); */ } else { @@ -147,7 +147,7 @@ OUTPUT: RETVAL CLEANUP: - free(res_str); + /* free(res_str); */ char * @@ -167,7 +167,7 @@ if (utf8_str) { q = stringprep_utf8_to_ucs4(utf8_str, -1, &len +); - free(utf8_str); + /* free(utf8_str); */ } else { @@ -182,7 +182,7 @@ tmp_str = malloc(MAX_DNSLEN*sizeof(char)); len2 = MAX_DNSLEN-1; res = punycode_encode(len, q, NULL, &len2, tmp_str); - free(q); + /* free(q); */ if (res != PUNYCODE_SUCCESS) { @@ -201,7 +201,7 @@ OUTPUT: RETVAL CLEANUP: - free(res_str); + /* free(res_str); */ char * @@ -239,7 +239,7 @@ if (utf8_str) { res_str = stringprep_convert(utf8_str, charset +, "UTF-8") ; - free(utf8_str); + /* free(utf8_str); */ } else { @@ -254,7 +254,7 @@ OUTPUT: RETVAL CLEANUP: - free(res_str); + /* free(res_str); */ char * @@ -274,7 +274,7 @@ OUTPUT: RETVAL CLEANUP: - free(res_str); + /* free(res_str); */ char * @@ -450,7 +450,7 @@ XSRETURN_UNDEF; } res = stringprep_profile(utf8_str, &tmp_str, "Nameprep +", 0); - free(utf8_str); + /* free(utf8_str); */ if (res != STRINGPREP_OK) { XSRETURN_UNDEF; @@ -458,18 +458,18 @@ if (tld) { q = stringprep_utf8_to_ucs4(tmp_str, -1, &len) +; - free(tmp_str); + /* free(tmp_str); */ if (!q) { XSRETURN_UNDEF; } res = tld_check_4t(q, len, &errpos, tld_table) +; - free(q); + /* free(q); */ } else { res = tld_check_8z(tmp_str, &errpos, NULL); - free(tmp_str); + /* free(tmp_str); */ } if (res == TLD_SUCCESS) { @@ -507,7 +507,7 @@ OUTPUT: RETVAL CLEANUP: - free(res_str); + /* free(res_str); */ SV *
    As you can see, all I've done is remove many of the free() calls. The are possibly other free() calls (not tested by the test suite) that also produce the "Free to wrong pool ..." error.

    UPDATE: The correct patch to apply is at https://rt.cpan.org/Ticket/Attachment/564402/285045/LibIDN_xs.diff . See Re: [Win32] "Free to wrong pool ..." error.

    Cheers,
    Rob
      I know this is an old post, but I need help getting Net::LibIDN installed in Windows. I successfully built libidn-1.12 as a static library using MinGW/MSYS and the instructions from syphilis, but now I get the following output when I create the make file...
      $ perl Makefile.PL Found LibIDN, with TLD checking support Checking if your kit is complete... Looks good Note (probably harmless): No library found for -lidn Note (probably harmless): No library found for -liconv Note (probably harmless): No library found for oldnames.lib Note (probably harmless): No library found for kernel32.lib Note (probably harmless): No library found for user32.lib Note (probably harmless): No library found for gdi32.lib Note (probably harmless): No library found for winspool.lib Note (probably harmless): No library found for comdlg32.lib Note (probably harmless): No library found for advapi32.lib Note (probably harmless): No library found for shell32.lib Note (probably harmless): No library found for ole32.lib Note (probably harmless): No library found for oleaut32.lib Note (probably harmless): No library found for netapi32.lib Note (probably harmless): No library found for uuid.lib Note (probably harmless): No library found for ws2_32.lib Note (probably harmless): No library found for mpr.lib Note (probably harmless): No library found for winmm.lib Note (probably harmless): No library found for version.lib Note (probably harmless): No library found for odbc32.lib Note (probably harmless): No library found for odbccp32.lib Note (probably harmless): No library found for msvcrt.lib Writing Makefile for Net::LibIDN
      ...and the following error when I run make:
      $ make make: *** No rule to make target `C:\Perl\libConfig.pm', needed by `Ma +kefile'. Stop.
      I feel like I'm so close, or that I'm missing something obvious. Any ideas?

      UPDATE: I've got Visual Studio 2005 installed, and if I try building with nmake, the build actually runs for a little until I get this error:
      fatal error C1083: Cannot open include file: 'stdint.h': No such file +or directory


      Thanks,
      Rob