in reply to Cannot compile Encode::Detect on Windows

Hi,
Here's a hack to build and install Encode-Detect-1.01 from source.

1) Copy include/nscore.h and include/prmem.h to src/nscore.h and src/prmem.h
2) Move Detect.pm from the top level source folder to 'lib/Encode/Detect.pm'. (You'll need to first create the lib/Encode directory.)
3) In Build.PL change  dist_version_from => 'Detect.pm', to dist_version_from => 'lib/Encode/Detect.pm', 4) In the MANIFEST file change Detect.pm to lib/Encode/Detect.pm.
5) Create My_Makefile.PL in the top level source folder (alongside existing Makefile.PL)

My_Makefile.PL looks like this:
use ExtUtils::MakeMaker; use Config; die "Wrong platform" if $Config{cc} ne 'cl' && $Config{cc} ne 'gcc'; WriteMakefile( NAME => 'Encode::Detect::Detector', CC => $Config{cc} eq 'cl' ? 'cl -TP' : 'g++', VERSION_FROM => 'Detector.pm', LIBS => $Config{make} eq 'nmake' ? '-L. -lns': '-L./src -lns', INC => '-I./src', );
With Microsoft Compilers and nmake:
Then build the library by running, in turn:
a) perl Makefile.PL CC="cl -TP"
b) nmake (terminates with error, but compiles the src/*.cpp files)
c) lib /out:libns.lib *.obj
d) nmake realclean (restores to what we started with + libns.lib + object files)
Now that we have the library, let's build the module:
e) perl My_Makefile.PL
f) nmake test (should pass test suite)
g) nmake install
h) nmake realclean (to return to what we started with)

With MinGW and dmake:
Then build the library by running, in turn:
a) perl Makefile.PL CC=g++
b) dmake (terminates with error, but compiles the src/*.cpp files)
c) cd src
d) ar -rc libns.a *.o
e) ranlib libns.a
f) cd ..
g) dmake realclean (restores to what we started with + src/libns.a)
Now that we have the library, let's build the module:
h) perl My_Makefile.PL
i) dmake test (should pass test suite)
j) dmake install
k) dmake realclean (to return to what we started with + src/libns.a)

Note that, for me, when building with nmake, the object files were all built in the top level source folder (instead of the 'src' folder, as happens with dmake). I can't guarantee that the behaviour in this regard will be the same for all versions of EU::MM - if it differs you will need to modify the above instructions acccordingly.

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: Cannot compile Encode::Detect on Windows
by posti (Novice) on Mar 09, 2010 at 10:02 UTC
    This doesn't seem to work with the latest ActivePerl (5.10.1.1007)

    Executing perl Makefile.PL CC=g++ reports
    C:\Packages\Encode-Detect-1.01>perl Makefile.PL CC="cl -TP" # running Build.PL --config cc=cl -TP cl : Command line warning D9035 : option 'o' has been deprecated and w +ill be rem oved in a future release compilet-1026621440.c 'dlltool' is not recognized as an internal or external command, operable program or batch file. LINK : warning LNK4044: unrecognized option '/o'; ignored LINK : warning LNK4044: unrecognized option '/Wl,--base-file,C:\DOCUME +~1\VMUser\ LOCALS~1\Temp\compilet.base'; ignored LINK : warning LNK4044: unrecognized option '/Wl,--image-base,0xa03000 +0'; ignore d LINK : fatal error LNK1181: cannot open input file 'C:\DOCUME~1\VMUser +\LOCALS~1\ Temp\compilet.dll' 'dlltool' is not recognized as an internal or external command, operable program or batch file. LINK : warning LNK4044: unrecognized option '/o'; ignored LINK : warning LNK4044: unrecognized option '/Wl,--image-base,0xa03000 +0'; ignore d LINK : fatal error LNK1181: cannot open input file 'C:\DOCUME~1\VMUser +\LOCALS~1\ Temp\compilet.dll' Creating new 'MYMETA.yml' with configuration results Creating new 'Build' script for 'Encode-Detect' version '1.01'

    Not sure if this is already an issue but following the guidelines above the nmake test fails and finally trying to make install reports this:
    blib\arch\auto\Encode\Detect\Detector\Detector.dll : fatal error LNK11 +20: 5 unre solved externals NMAKE : fatal error U1077: '"c:\Program Files\Microsoft Visual Studio +9.0\VC\BIN \link.EXE"' : return code '0x460' Stop.

    It's a pity since it was working fine under perl 5.8.8