From: Dilbert on
[ subject changed to: "MinGW and Perl 5.12 - Windows 64 bits
ActiveState" ]

On 14 mai, 15:25, Dilbert <dilbert1...(a)gmail.com> wrote:
> On 14 mai, 14:01, Bart Lateur <bart.lat...(a)telenet.be> wrote:
> > Dilbert wrote:
> > >I know, I can get MinGW64 athttp://mingw-w64.sourceforge.net/orI
> > >can grab the freely available "Microsoft Platform SDK for Windows
> > >Server 2003 R2", but I like the "no brain, no pain" philosophy of a
> > >"ppm install MinGW". So I tried "ppm install MinGW" on Activestate
> > >Perl 5.12 - Windows 64 bits, but there is still no MinGW Package
> > >available for 64 bits on the Activestate repo.
>
> > If your Perl is 32 bits, then your modules should be built for 32 bits,
> > too.
>
> I have got two computers:
>
>  - one computer with Windows Vista 64 bits and Activestate Perl 5.12 -
> 64 bits
>  - another computer with Windows XP 32 bits and Activestate Perl 5.12
> - 32 bits
>
> As already described in the other posts in this thread, I am happy
> with "ppm install MinGW" on my 32 bits computer.
>
> However, on my other 64 bits computer, (although I can perfectly
> understand that "ppm install MinGW" does not work on a 64 bit Windows
> system) I still need to have a C-compiler to build XS-modules from
> CPAN.
>
> First I tried to get MinGW64 athttp://mingw-w64.sourceforge.net/, but
> I could not find any package/zip file that contained the required pre-
> compiled *.exe files for Windows 64 bits.
>
> Then I tried the freely available "Microsoft Platform SDK for Windows
> Server 2003 R2", but honestly, this is a nightmare: first of all, the
> download+install of VC++/Platform SDK is more than 200 megs, then the
> linker complains with a message: fatal error LNK1112: module machine
> type 'X86' conflicts with target machine type 'x64'.
>
> I was looking at the articlehttp://jenshuebel.wordpress.com/2009/02/12/visual-c-2008-express-edit...
> to fix my problems, but on my system I can't even find the slightest
> trace of any of the x64/amdx64 directories/dlls mentioned in the
> article.
>
> I can understand that a big company like Activestate can afford to use
> a MS Visual C++ compiler, but I am simply not clever enough to use the
> freely available compiler from Microsoft.

It looks very much as if there simply is no 64 bits in the free
available compiler from Microsoft, only 32 bits :(

I am just thinking: is there not a manipulation somewhere in "use
Config" that tricks Makefile.PL and Build.PL into thinking it was on a
32 bit platform ? -- Maybe then the compile and link will succeed as a
32 bit application, and the 32 bit program should work fine, even with
a 64 bit Perl ? -- or is my thinking wrong ?

> My only hope is that the good people who gave us "ppm install MinGW"
> on 32 bits, will repeat their efforts and release the same for 64
> bits.

Whatever the outcome of my battle with MS VC++ will be, I will be
relieved when "ppm install MinGW" works on 64 bit Windows.
From: sisyphus on
On May 15, 3:41 am, Dilbert <dilbert1...(a)gmail.com> wrote:

>
> It looks very much as if there simply is no 64 bits in the free
> available compiler from Microsoft, only 32 bits :(

It's still there - though it looks a 32 bit application is being
found.
What command are you running to set the environment ?
What does the 'cl /?' output begin with ? It should be something like:

Microsoft (R) C/C++ Optimizing Compiler Version 14.00.40310.41 for
AMD64
Copyright (C) Microsoft Corporation. All rights reserved.

>
> Whatever the outcome of my battle with MS VC++ will be, I will be
> relieved when "ppm install MinGW" works on 64 bit Windows.

According to Jan Dubois, that probably won't be for a couple of months
(at least). ActivePerl 5.12.0 needs some patching before it will work
with the MinGW64 compilers. I have patches that enable this (included
below)- they're a bit of a hack, and quite possibly *not* the way that
ActiveState will deal with the issues. But they've been working fine
for me, and you're welcome to give them a try. (I'd be interested to
hear of any problems you strike if you do use them - feel free to
email me at my CPAN address.)

For the MinGW64 compiler, you go to http://sourceforge.net/projects/mingw-w64/files
, as you've already discovered. Under "Toolchains targetting Win64"
grab either one of the "personal builds" or one of the "automated
builds" that has been built for win64 mingw (not for linux or cygwin)
- and make sure it's a 64-bit build (as they're also providing a 32-
bit compiler). The "automated builds" are a cross-compiler with the
names of the executables prefixed with "x86_64-w64-mingw32-" (ie
"x86_64-w64-mingw32-gcc.exe", etc.), so it might be simpler if you
choose the "sezero_20100428" build ("mingw-w64-bin_x86_64-
mingw_20100428_sezero.zip"). My patches accommodate both types of
build.

Then just unzip and add the bin folder to the path.

Cheers,
Rob

Patch to lib/ExtUtils/MM_Win32.pm (ActivePerl build 1200):

##################################################
--- MM_Win32.pm_orig Sat Apr 17 13:38:04 2010
+++ MM_Win32.pm Wed Apr 21 17:40:30 2010
@@ -33,7 +33,9 @@

my $BORLAND = $Config{'cc'} =~ /\bbcc/i ? 1 : 0;
my $GCC = $Config{'cc'} =~ /\bgcc/i ? 1 : 0;
-my $DLLTOOL = $Config{'dlltool'} || 'dlltool';
+my $dlltool = $Config{'cc'} =~ /x86_64\-w64\-mingw32\-/i ? 'x86_64-
w64-mingw32-dlltool'
+ : 'dlltool';
+my $DLLTOOL = $Config{'dlltool'} || $dlltool;


=head2 Overridden methods
@@ -359,8 +361,17 @@

sub init_linker {
my $self = shift;
-
- $self->{PERL_ARCHIVE} = "\$(PERL_INC)\\$Config{libperl}";
+
+ if($GCC &&
+ $Config{libperl} =~ /\.lib/ &&
+ $Config{archname} =~ /\-x64/) {
+ my $libperl = $Config{libperl};
+ $libperl =~ s/\.lib/\.dll/;
+ $self->{PERL_ARCHIVE} = "$Config{bin}\\$libperl";
+ }
+ else {
+ $self->{PERL_ARCHIVE} = "\$(PERL_INC)\\$Config{libperl}";
+ }
$self->{PERL_ARCHIVE_AFTER} = '';
$self->{EXPORT_LIST} = '$(BASEEXT).def';
}

##################################################

Patch to lib/ActivePerl/Config.pm (ActivePerl build 1200):

##################################################
--- Config.pm_orig Sat Apr 17 12:27:02 2010
+++ Config.pm Mon May 3 12:54:59 2010
@@ -34,8 +34,11 @@
quadtype
uquadtype
d_casti32
-);
+ dlltool
+); # libperl needs to be inserted into above list (and
appropriate _override() uncommented below)
+ # if we want to link to libperl512.a instead of perl512.dll -
SISYPHUS
my $compiler_env_initialized;
+my $gcc_pre = '';

use Config ();
my $CONFIG_OBJ = tied %Config::Config;
@@ -98,12 +101,16 @@
}
elsif ($^O eq "MSWin32" && (_gcc_requested() || !
ActiveState::Path::find_prog(_orig_conf("cc")))) {
my $gcc = _find_prog("gcc");
+ if(!$gcc) {
+ $gcc_pre = 'x86_64-w64-mingw32-';
+ $gcc = _find_prog("${gcc_pre}gcc");
+ }
if (!$gcc && _install_mingw($key)) {
$gcc = _find_prog("gcc");
}
if ($gcc) {
# assume MinGW or similar is available
- $gcc = _get_short_path_name($gcc);
+ unless($gcc_pre) {$gcc = _get_short_path_name($gcc);}
$gcc =~ s,\\,/,g;
my($mingw) = $gcc =~ m,^(.*)/bin/gcc\.exe$,;
if (defined $mingw) {
@@ -134,7 +141,7 @@
# New: "-lfoo -lbar"
my @libs = split / +/, _orig_conf($key);
# Filter out empty prefix and oldnames.lib
- @libs = grep {$_ && $_ ne "oldnames.lib"} @libs;
+ @libs = grep {$_ && $_ ne "oldnames.lib" && $_ ne
"bufferoverflowU.lib"} @libs;
# Remove '.lib' extension and add '-l' prefix
s/(.*)\.lib$/-l$1/ for @libs;
_override($key, join(' ', @libs));
@@ -150,24 +157,25 @@
_override("cpp", "$gcc -E");
_override("cpprun", "$gcc -E");
_override("cppminus", "-");
- _override("ar", _find_prog("ar"));
- _override("ld", _find_prog("g++"));
+ _override("ar", _find_prog("${gcc_pre}ar"));
+ _override("ld", _find_prog("${gcc_pre}g++"));
_override("_a", ".a");
_override("_o", ".o");
_override("obj_ext", ".o");
_override("lib_ext", ".a");
- _override("optimize", "-O2");
+ _override("optimize", "-s -O2");
_override("i64type", "long long");
_override("u64type", "unsigned long long");
_override("quadtype", "long long");
_override("uquadtype", "unsigned long long");
_override("d_casti32", "define");
+ #_override("libperl", "libperl512.a");

# Extract all library paths from lddlflags
my @libpaths = map "-L$_", map /^-libpath:(.+)/,
_orig_conf("lddlflags") =~ /(?=\S)(?>[^"\s]+|"[^"]*")+/g;
- _override("lddlflags", join(" ", "-mdll", @libpaths));
- _override("ldflags", join(" ", @libpaths));
+ _override("lddlflags", join(" ", "-s -mdll", @libpaths));
+ _override("ldflags", join(" ", '-s', @libpaths));
}
elsif (_gcc_requested()) {
warn "Cannot find gcc on PATH\n"

##################################################
From: Dilbert on
On 15 mai, 09:56, sisyphus <sisyphus...(a)gmail.com> wrote:
> On May 15, 3:41 am, Dilbert <dilbert1...(a)gmail.com> wrote:
> > It looks very much as if there simply is no 64 bits in the free
> > available compiler from Microsoft, only 32 bits :(
>
> It's still there - though it looks a 32 bit application is being
> found.
> What command are you running to set the environment ?
> What does the 'cl /?' output begin with ? It should be something like:
>
> Microsoft (R) C/C++ Optimizing Compiler Version 14.00.40310.41 for
> AMD64
> Copyright (C) Microsoft Corporation.  All rights reserved.

My "cl" clearly indicates a 32 bit application:

++ C:\>cl /?
++ Compilateur d'optimisation Microsoft (R) 32 bits C/C++
++ version 15.00.30729.01 pour 80x86
++ Copyright (C) Microsoft Corporation. All rights reserved.

However, I am on 64 bit Windows Vista with a 64 bit Activestate Perl
installation:

++ C:\>perl -v
++ This is perl 5, version 12, subversion 0 (v5.12.0) built for
++ MSWin32-x64-multi-thread
++ (with 1 registered patch, see perl -V for more detail)
++ Copyright 1987-2010, Larry Wall
++ Binary build 1200 [292396] provided by ActiveState
++ http://www.ActiveState.com
++ Built Apr 10 2010 22:58:59

I have downloaded the freely available VC++ compiler from
http://msdn.microsoft.com/fr-fr/express/aa975050.aspx

The vcvarsall.bat command that sets the environment variables is
located in C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC:

++ C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>dir
++ Le volume dans le lecteur C s'appelle HP
++ Le numéro de série du volume est BA3E-0466
++
++ Répertoire de C:\Program Files (x86)\Microsoft Visual Studio
9.0\VC
++
++ 15/05/2010 11:45 <REP> .
++ 15/05/2010 11:45 <REP> ..
++ 14/05/2010 13:20 <REP> bin
++ 13/05/2010 20:17 <REP> Express
++ 13/05/2010 20:18 <REP> include
++ 13/05/2010 20:18 <REP> lib
++ 13/05/2010 20:17 <REP> Profile
++ 13/05/2010 20:17 <REP> redist
++ 13/05/2010 20:17 <REP> VCNewItems
++ 13/05/2010 20:18 <REP> vcpackages
++ 13/05/2010 20:18 <REP> VCProjectDefaults
++ 13/05/2010 20:18 <REP> vcprojectitems
++ 13/05/2010 20:18 <REP> vcprojects
++ 05/01/2005 16:51 1 247 vcvarsall.bat
++ 13/05/2010 20:17 <REP> VCWizards
++ 1 fichier(s) 1 247 octets

Here is an extract from "vcvarsall.bat":

++ @echo off
++ if "%1" == "" goto x86
++ if not "%2" == "" goto usage
++
++ if /i %1 == x86 goto x86
++ if /i %1 == amd64 goto amd64
++ if /i %1 == x64 goto amd64
++ if /i %1 == ia64 goto ia64
++ if /i %1 == x86_amd64 goto x86_amd64
++ if /i %1 == x86_ia64 goto x86_ia64
++ goto usage
++
++ :x86
++ if not exist "%~dp0bin\vcvars32.bat" goto missing
++ call "%~dp0bin\vcvars32.bat"
++ goto :eof
++
++ :amd64
++ if not exist "%~dp0bin\amd64\vcvarsamd64.bat" goto missing
++ call "%~dp0bin\amd64\vcvarsamd64.bat"
++ goto :eof
++
++ :ia64
++ if not exist "%~dp0bin\ia64\vcvarsia64.bat" goto missing
++ call "%~dp0bin\ia64\vcvarsia64.bat"
++ goto :eof
++
++ :x86_amd64
++ if not exist "%~dp0bin\x86_amd64\vcvarsx86_amd64.bat" goto missing
++ call "%~dp0bin\x86_amd64\vcvarsx86_amd64.bat"
++ goto :eof
++
++ :x86_ia64
++ if not exist "%~dp0bin\x86_ia64\vcvarsx86_ia64.bat" goto missing
++ call "%~dp0bin\x86_ia64\vcvarsx86_ia64.bat"
++ goto :eof

I have tried the command vcvarsall with "amd64", "x64", "ia64",
"x86_amd64" and with "x86_ia64", but no success:

++ C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>vcvarsall
amd64
++ The specified configuration type is missing. The tools for the
++ configuration might not be installed.

++ C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>vcvarsall x64
++ The specified configuration type is missing. The tools for the
++ configuration might not be installed.

++ C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>vcvarsall
ia64
++ The specified configuration type is missing. The tools for the
++ configuration might not be installed.

++ C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>vcvarsall
x86_amd64
++ The specified configuration type is missing. The tools for the
++ configuration might not be installed.

++ C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>vcvarsall
x86_ia64
++ The specified configuration type is missing. The tools for the
++ configuration might not be installed.

++ C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin>dir
++ Le volume dans le lecteur C s'appelle HP
++ Le numéro de série du volume est BA3E-0466

Well, not surprising at all, because the corresponding sub directories
("bin\amd64", "bin\ia64", "bin\x86_amd64" and "bin\x86_ia64") simply
do not exist:

++ Répertoire de C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC
\bin
++
++ 14/05/2010 13:20 <REP> .
++ 14/05/2010 13:20 <REP> ..
++ 13/05/2010 20:17 <REP> 1036
++ 31/07/2008 15:52 165 376 atlprov.dll
++ 31/07/2008 15:52 77 312 bscmake.exe
++ 31/07/2008 15:52 677 872 c1.dll
++ 31/07/2008 15:52 2 326 520 c1xx.dll
++ 31/07/2008 15:52 2 363 888 c2.dll
++ 31/07/2008 15:52 129 520 cl.exe
++ 29/07/2008 02:57 289 cl.exe.config
++ 31/07/2008 15:52 33 784 cvtres.exe
++ 31/07/2008 15:52 17 920 dumpbin.exe
++ 31/07/2008 15:52 17 920 editbin.exe
++ 13/05/2010 20:18 <REP> fr
++ 31/07/2008 15:52 17 912 lib.exe
++ 31/07/2008 15:06 801 272 link.exe
++ 29/07/2008 02:57 289 link.exe.config
++ 31/07/2008 15:52 361 968 ml.exe
++ 31/07/2008 13:31 72 192 msobj80.dll
++ 29/07/2008 13:36 193 536 mspdb80.dll
++ 29/07/2008 13:36 288 768 mspdbcore.dll
++ 29/07/2008 13:36 107 520 mspdbsrv.exe
++ 31/07/2008 15:52 94 200 nmake.exe
++ 31/07/2008 15:52 20 480 undname.exe
++ 07/03/2007 16:44 31 vcvars32.bat
++ 31/07/2008 15:52 40 448 xdcmake.exe
++ 29/07/2008 02:57 289 xdcmake.exe.config
++ 23 fichier(s) 7 809 306 octets

What does exist, however, is "bin\vcvars32.bat", so let's try the only
option that's available: "vcvarsall x86"

++ C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>vcvarsall x86
++ Setting environment for using Microsoft Visual Studio 2008 x86
tools.

Well, it's certainly not 64 bits, but as I said, it's the only option
available.

Here are the relevant environment variables:

C:\>set

INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio 9.0\Include;C:
\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Include;C:\Program
Files\Microsoft SDKs\Windows\v6.1\Include;C:\Program Files\Microsoft
SDKs\Windows\v6.1\Include\gl; C:\Program Files (x86)\Microsoft Visual
Studio 9.0\VC\include

LIB=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Lib\amd64;C:
\Program Files\Microsoft SDKs\Windows\v6.1\Lib\X64;C:\Program Files
(x86)\Microsoft Visual Studio 9.0\VC\lib

LIBPATH=C:\Windows\Microsoft.NET\Framework\v3.5;C:\Windows
\Microsoft.NET\Framework\v2.0.50727;C:\Program Files (x86)\Microsoft
Visual Studio 9.0\VC\LIB

Path=C:\Perl64\site\bin;C:\Perl64\bin;C:\Windows\system32;C:\Windows;C:
\Windows\System32\Wbem;c:\Program Files (x86)\Microsoft SQL Server
\100\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS
\Binn\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin

> > Whatever the outcome of my battle with MS VC++ will be, I will be
> > relieved when "ppm install MinGW" works on 64 bit Windows.
>
> According to Jan Dubois, that probably won't be for a couple of months
> (at least). ActivePerl 5.12.0 needs some patching before it will work
> with the MinGW64 compilers. I have patches that enable this (included
> below)- they're a bit of a hack, and quite possibly *not* the way that
> ActiveState will deal with the issues. But they've been working fine
> for me, and you're welcome to give them a try. (I'd be interested to
> hear of any problems you strike if you do use them - feel free to
> email me at my CPAN address.)
>
> For the MinGW64 compiler, you go tohttp://sourceforge.net/projects/mingw-w64/files
> , as you've already discovered. Under "Toolchains targetting Win64"
> grab either one of the "personal builds" or one of the "automated
> builds" that has been built for win64 mingw (not for linux or cygwin)
> - and make sure it's a 64-bit build (as they're also providing a 32-
> bit compiler). The "automated builds" are a cross-compiler with the
> names of the executables prefixed with "x86_64-w64-mingw32-" (ie
> "x86_64-w64-mingw32-gcc.exe", etc.), so it might be simpler if you
> choose the "sezero_20100428" build ("mingw-w64-bin_x86_64-
> mingw_20100428_sezero.zip"). My patches accommodate both types of
> build.
>
> Then just unzip and add the bin folder to the path.
> Patch to lib/ExtUtils/MM_Win32.pm (ActivePerl build 1200):
> Patch to lib/ActivePerl/Config.pm (ActivePerl build 1200):

I will try downloading "mingw-w64-bin_x86_64-
mingw_20100428_sezero.zip" with your suggested patches to "lib/
ExtUtils/MM_Win32.pm" and "lib/ActivePerl/Config.pm".

I will let you know how I get on.

Thanks for your help
From: Ben Morrow on

Quoth Dilbert <dilbert1999(a)gmail.com>:
>
> I have tried the command vcvarsall with "amd64", "x64", "ia64",
> "x86_amd64" and with "x86_ia64", but no success:
>
> ++ C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>vcvarsall
> amd64
> ++ The specified configuration type is missing. The tools for the
> ++ configuration might not be installed.

> Well, not surprising at all, because the corresponding sub directories
> ("bin\amd64", "bin\ia64", "bin\x86_amd64" and "bin\x86_ia64") simply
> do not exist:

It looks like you've either downloaded the wrong package, or not
installed everything. Did the installer ask you any questions about
64bit versions of the compiler?

Ben

From: Dilbert on
On 15 mai, 13:37, Ben Morrow <b...(a)morrow.me.uk> wrote:
> Quoth Dilbert <dilbert1...(a)gmail.com>:
> > I have tried the command vcvarsall with "amd64", "x64", "ia64",
> > "x86_amd64" and with "x86_ia64", but no success:
>
> > ++ C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>vcvarsall
> > amd64
> > ++ The specified configuration type is missing.  The tools for the
> > ++ configuration might not be installed.
> > Well, not surprising at all, because the corresponding sub directories
> > ("bin\amd64", "bin\ia64", "bin\x86_amd64" and "bin\x86_ia64") simply
> > do not exist:
>
> It looks like you've either downloaded the wrong package,

I have downloaded it from
http://msdn.microsoft.com/fr-fr/express/aa975050.aspx

is this the correct package ?
is this the latest package?

> or not installed everything. Did the installer ask you any
> questions about 64bit versions of the compiler?

I can't remember any question about 64 or 32 bit versions during the
install.

Does anybody know
- where to download and
- how to install
the free MS VC++ Express compiler for 64 bits ?