Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Net::LibIDN in Windows, is it possible?

by wilsond (Scribe)
on Feb 05, 2009 at 13:57 UTC ( [id://741544]=perlquestion: print w/replies, xml ) Need Help??

wilsond has asked for the wisdom of the Perl Monks concerning the following question:

I'm having a terrible time getting Net::LibIDN to work in Windows via ActivePerl. Is this even possible? The GNU Libidn site claims it works in Windows, so it seems that it should be.

None of the PPM repositories seem to have it (they all list it as buggy/failed) and I can't get it to build via CPAN. (Though I can build pretty much any other module I need)

The error I'm getting during build:

CPAN.pm: Going to build T/TH/THOR/Net-LibIDN-0.11.tar.gz Set up gcc environment - 3.4.5 (mingw-vista special r3) 'cc' is not recognized as an internal or external command, operable program or batch file. __test1.c:1:18: idna.h: No such file or directory This module requires GNU Libidn, which could not be found. THOR/Net-LibIDN-0.11.tar.gz C:\Perl\bin\perl.exe Makefile.PL INSTALLDIRS=site -- NO Makefile cre +ated Running make test Make had some problems, won't test Running make install Make had some problems, won't install

Now, I know it needs GNU Libidn, but how do I go about making this happen? Do I just need to make the code available somehow, or do I have to fully install GNU Libidn? And if I have to install it, will I have to install it on every Windows computer that runs a copy of my code?

Edit: Update on errors: (downloaded libidn from GNU site and extracted it into subfolder named libidn-1.9 in the cwd)

C:\Perl\cpan\build\Net-LibIDN-0.11-QaNUHQ>perl Makefile.PL --with-libi +dn=libidn- 1.9 --with-libidn-inc=libidn-1.9\lib Set up gcc environment - 3.4.5 (mingw-vista special r3) In file included from __test1.c:1: libidn-1.9/lib/idna.h:31:38: idn-int.h: No such file or directory In file included from __test1.c:1: libidn-1.9/lib/idna.h:67: error: syntax error before '*' token libidn-1.9/lib/idna.h:69: error: syntax error before '*' token libidn-1.9/lib/idna.h:74: error: syntax error before '*' token libidn-1.9/lib/idna.h:82: error: syntax error before '*' token libidn-1.9/lib/idna.h:86: error: syntax error before "uint32_t" This module requires GNU Libidn, which could not be found.

Thanks a ton, in advance.


While I ask a lot of Win32 questions, I hate Windows with a passion. That's the problem with writing a cross-platform program. I'm a Linux user myself. I wish more people were.
If you want to do evil, science provides the most powerful weapons to do evil; but equally, if you want to do good, science puts into your hands the most powerful tools to do so.
- Richard Dawkins

Replies are listed 'Best First'.
Re: Net::LibIDN in Windows, is it possible?
by Corion (Patriarch) on Feb 05, 2009 at 14:01 UTC

    I guess your stated hatred for the platform you're working on prevented you from showing us what exact problems you're facing while installing Net::LibIDN. Most likely this is a problem of not having the prerequisites, like (likely) the libidn external library. But it's hard to know without knowing more specifics.

    After Update:

    Set up gcc environment - 3.4.5 (mingw-vista special r3) ... 'cc' is not recognized as an internal or external command, operable program or batch file. __test1.c:1:18: idna.h: No such file or directory

    This seems to be a configuration problem with the module, because it seems to be hardcoded to use cc, a program which is not installed on your machine. Most likely you can fix that by replacing every instance of cc by $Config{cc}, which for your installation likely should be gcc or gcc.exe.

    But that seems not to be all, because something somewhere seems to find your gcc, which then complains about idna.h not being found. So maybe you don't have either the environment variables for your C compiler set up to also include the paths of the headers and library files ($ENV{INCLUDE}, $ENV{LIB}), or you don't have these.

    As Net::LibIDN is under the Artistic License, it's unlikely that it includes the libidn libraries.

      it's unlikely that it includes the libidn libraries

      It doesn't, get them from libidn.

        Here are the current errors I get now.

        It complains about idn-int.h. That file is in libidn-1.9\win32\include, not libidn-1.9\lib like idna.h is. Any ideas on how to use both directories at the same time? (I'm sure I sound like an idiot, sorry.)

        C:\Perl\cpan\build\Net-LibIDN-0.11-QaNUHQ>perl Makefile.PL --with-libi +dn=libidn- 1.9 --with-libidn-inc=libidn-1.9\lib Set up gcc environment - 3.4.5 (mingw-vista special r3) In file included from __test1.c:1: libidn-1.9/lib/idna.h:31:38: idn-int.h: No such file or directory In file included from __test1.c:1: libidn-1.9/lib/idna.h:67: error: syntax error before '*' token libidn-1.9/lib/idna.h:69: error: syntax error before '*' token libidn-1.9/lib/idna.h:74: error: syntax error before '*' token libidn-1.9/lib/idna.h:82: error: syntax error before '*' token libidn-1.9/lib/idna.h:86: error: syntax error before "uint32_t" This module requires GNU Libidn, which could not be found.

        While I ask a lot of Win32 questions, I hate Windows with a passion. That's the problem with writing a cross-platform program. I'm a Linux user myself. I wish more people were.
        If you want to do evil, science provides the most powerful weapons to do evil; but equally, if you want to do good, science puts into your hands the most powerful tools to do so.
        - Richard Dawkins

      Sorry, I had submitted my question before I was really done. I just added the extra info.


      While I ask a lot of Win32 questions, I hate Windows with a passion. That's the problem with writing a cross-platform program. I'm a Linux user myself. I wish more people were.
      If you want to do evil, science provides the most powerful weapons to do evil; but equally, if you want to do good, science puts into your hands the most powerful tools to do so.
      - Richard Dawkins
Re: Net::LibIDN in Windows, is it possible?
by syphilis (Archbishop) on Feb 05, 2009 at 23:52 UTC
    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
      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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://741544]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-25 14:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found