in reply to Cannot compile Encode::Detect on Windows

The problem is that the file: detector.xs is being compiled as C, but it contains C++ extensions:

extern "C" {

The file compiles clean (with a couple of trivial warnings), if you add option -TP to cause the compiler to treat the file as C++.

Unfortunately, as with all these build mechanisms, the process is so stupidly convoluted that working out how to add a simple compiler option is your typical OO maze of dark, twisty packages.

The way I tested it was:

  1. start the compile (using command nmake) at the command line and the immediately pause it using ^S.
  2. Switch to another session, and make a copy of the file under a different name: Encode-Detect-1.01\lib\Encode\Detect\Detector.ccs.

    This is a compiler "options response file" that is generated automatically, but then deleted.

  3. Switch back to the first session and hit any key allowing the compile to continue to failure.
  4. Edit the file you saved and add -TP as a new last line.
  5. Rename the file back to Encode-Detect-1.01\lib\Encode\Detect\Detector.ccs
  6. Switch back to the first session, and C&P the last compiler command issued by the nmake. It should look something like this:
    C:\Perl64\packages\Encode-Detect-1.01>cl -nologo -c @"lib\Encode\Detec +t\Detector.ccs" -Fo"lib\Encode\Detect\Detector.obj" "lib\Encode\Detec +t\Detector.c" Detector.c lib\Encode\Detect\Detector.xs(79) : warning C4267: 'argument' : conver +sion from 'size_t' to 'PRUint32', possible loss of data lib\Encode\Detect\Detector.xs(109) : warning C4267: 'argument' : conve +rsion from 'size_t' to 'PRUint32', possible loss of data

At that point, reissuing the nmake ought to allow things to complete--but it doesn't:

C:\Perl64\packages\Encode-Detect-1.01>nmake Microsoft (R) Program Maintenance Utility Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved. C:\Perl64\bin\perl.exe Build --makefile_env_macros 1 ExtUtils::Mkbootstrap::Mkbootstrap('blib\arch\auto\Encode\Detect\Detec +tor\Detector.bs') Generating script 'lib\Encode\Detect\Detect.lds' link @"lib\Encode\Detect\Detect.lds" -out:"blib\arch\auto\Encode\Detec +t\Detector\Detector.dll" LINK : warning LNK4044: unrecognized option '/lstdc++'; ignored Detect.def : error LNK2001: unresolved external symbol boot_Encode__De +tect Detect.def : error LNK2001: unresolved external symbol boot_Encode__De +tect lib\Encode\Detect\Detect.lib : fatal error LNK1120: 2 unresolved exter +nals mt -nologo -manifest "lib\Encode\Detect\Detect.dll.manifest" -outputre +source:"blib\arch\auto\Encode\Detect\Detector\Detector.dll";2 lib\Encode\Detect\Detect.dll.manifest : general error c1010070: Failed + to load and parse the manifest. The system cannot find the file spec +ified. Manifying blib\lib/Encode/Detect.pm -> blib\libdoc\Encode.Detect.3 Manifying blib\lib/Encode/Detect/Detector.pm -> blib\libdoc\Encode.Det +ect.Detector.3 HTMLifying blib\lib\Encode\Detect.pm -> blib\libhtml\site\lib\Encode\D +etect.html Build: blib\lib\Encode\Detect.pm: cannot resolve L<Encode> in paragrap +h 18. HTMLifying blib\lib\Encode\Detect\Detector.pm -> blib\libhtml\site\lib +\Encode\Detect\Detector.html

And I haven't been able to hack my way past that one because again, the autogenerate linker response file: lib\Encode\Detect\Detect.lds is deleted automatically (why?), and it happens too fast for me to be able to intervene.

So, your only choice is to try and navigate that purile maze of OO dark, twisty packages to try and work out what is generated inside that file. If you succeed in doing that, then you might stand some chance of working out why it is wrong.

Or you can throw the problem back at the authors of the module and the build process and wait until they decide who is in the wrong and put it right. Say, 3 years from now if you are lucky!


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^2: Cannot compile Encode::Detect on Windows
by syphilis (Archbishop) on Apr 17, 2009 at 08:37 UTC
    The file compiles clean ... if you add option -TP to cause the compiler to treat the file as C++ .

    Easiest way to achieve that is to start the build process with perl Makefile.PL CC="cl -TP".
    For me, that allows Encode-Detect-1.01 to build ok (though I first had to copy the 2 header files that are in the 'include' folder into the 'src' folder). However, I strike runtime problems when running the test suite:
    Can't locate loadable object for module Encode::Detect::Detector
    I haven't the time at the moment to take a look at what's going wrong there. It's the same problem if I build with MinGW (starting with perl Makefile.PL CC="g++").

    Cheers,
    Rob

      That adds the -TP to the compiler commands for every file, rather than just the one that needs it. In this case, that doesn't seem to prevent the rest from compiling ok, but is that always true?

      But I don't see how to use that syntax to remove unneeded options?

      Didn't you see all the noise and errors that I'm seeing at the linker stage?

      Using response files instead of huge command lines is a step forward over EU::MM--but automatically deleting them so the programmer cannot look to see what options were used and perhaps try adjusting them, before sitting down to try and work out how to pursuade build.pl to produce what you've discovered works, is three steps backward.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Didn't you see all the noise and errors that I'm seeing at the linker stage?

        Yes - I see the same as you. Last night I didn't have much time to investigate - tonight I *do* have the time, but it looks to me that we're dealing with Module::Build issues, and that means I don't have the inclination. (It's not a matter of not caring ... rather a matter of wanting to avoid the feelngs of extreme annoyance that invariably arise within me whenever I *do* investigate Module::Build.)

        Coming up with a solution that involves only ExtUtils::MakeMaker and that works on Windows does, however, strike me as the sort of exercise that I ought to do. (It will probably be no less aggravating than investigating Module::Build ;-)

        Cheers,
        Rob