# Link with the 64-bit libraries, Luke!

## A. Sinan Unur

### April 08, 2014

I had some trouble building perl 5.18.2 after upgrading to Windows 8.1 Pro.

While the test failures seemed to be confined to Module::Build and ExtUtils::ParseXS, the fact that the failed tests involved XS and dynamic libraries meant I could not simply ignore them.

As my first step towards solving the issue, I removed everything related to Visual Studio Express 2013 from my system. I also uninstalled all SDKs other than the Windows 7.1 SDK which does come with a 64-bit command line build environment.

My first attempt at rebuilding resulted in exactly the same test failures.

The failures persisted after installing the distribution, and trying to build the modules from the command line.

Something was so borken that I was getting LNK 2001 errors for even TerminateProcess … I had initially focused on the more interesting __security_cookie, but that was a red herring.

Looking over the bundled `win32\Makefile`, I realized the problem (and therefore also the solution) was staring me right in the face. The original `win32\Makefile` has:

```CCHOME          = \$(MSVCDIR)
CCINCDIR        = \$(CCHOME)\include
CCLIBDIR        = \$(CCHOME)\lib```

The SDK command prompt does not set `%MSVCDIR%`, so I had set that to `C:\Program Files\Microsoft SDKs\Windows\v7.1`.

Well, there is that small matter of linking with the correct libraries, which happen to be in the `lib\x64` under that!

After changing those to:

```CCHOME          = C:\Program Files\Microsoft SDKs\Windows\v7.1
CCINCDIR        = \$(CCHOME)\include
CCLIBDIR        = \$(CCHOME)\lib\x64```

`nmake test` went without a hitch.

Then, just to make sure, I downloaded ExtUtils::ParseXS, and did a `perl Makefile.PL`, `nmake test`, with the following results:

```Microsoft (R) Program Maintenance Utility Version 10.00.30319.01

cp lib/ExtUtils/ParseXS/Utilities.pm blib\lib\ExtUtils\ParseXS\Utilities.pm
cp lib/ExtUtils/ParseXS/Eval.pm blib\lib\ExtUtils\ParseXS\Eval.pm
cp lib/ExtUtils/Typemaps/Type.pm blib\lib\ExtUtils\Typemaps\Type.pm
cp lib/ExtUtils/Typemaps/Cmd.pm blib\lib\ExtUtils\Typemaps\Cmd.pm
cp lib/ExtUtils/ParseXS.pod blib\lib\ExtUtils\ParseXS.pod
cp lib/ExtUtils/ParseXS.pm blib\lib\ExtUtils\ParseXS.pm
cp lib/ExtUtils/ParseXS/Constants.pm blib\lib\ExtUtils\ParseXS\Constants.pm
cp lib/ExtUtils/Typemaps/OutputMap.pm blib\lib\ExtUtils\Typemaps\OutputMap.pm
cp lib/ExtUtils/ParseXS/CountLines.pm blib\lib\ExtUtils\ParseXS\CountLines.pm
cp lib/ExtUtils/xsubpp blib\lib\ExtUtils\xsubpp
cp lib/ExtUtils/Typemaps/InputMap.pm blib\lib\ExtUtils\Typemaps\InputMap.pm
cp lib/ExtUtils/Typemaps.pm blib\lib\ExtUtils\Typemaps.pm
C:\opt\perl-5.18.2\bin\perl.exe -MExtUtils::Command -e cp -- lib/ExtUtil
s/xsubpp blib\script\xsubpp
pl2bat.bat blib\script\xsubpp
C:\opt\perl-5.18.2\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_har
ness(0, 'blib\lib', 'blib\arch')" t/*.t
t/001-basic.t ............................ ok
t/002-more.t ............................. ok
t/003-usage.t ............................ ok
t/101-standard_typemap_locations.t ....... ok
t/102-trim_whitespace.t .................. ok
t/103-tidy_type.t ........................ ok
t/104-map_type.t ......................... ok
t/105-valid_proto_string.t ............... ok
t/106-process_typemaps.t ................. ok
t/108-map_type.t ......................... ok
t/109-standard_XS_defs.t ................. ok
t/110-assign_func_args.t ................. ok
t/111-analyze_preprocessor_statements.t .. ok
t/112-set_cond.t ......................... ok
t/113-check_cond_preproc_statements.t .... ok
t/114-blurt_death_Warn.t ................. ok
t/115-avoid-noise.t ...................... ok
t/501-t-compile.t ........................ ok
t/510-t-bare.t ........................... ok
t/511-t-whitespace.t ..................... ok
t/512-t-file.t ........................... ok
t/513-t-merge.t .......................... ok
t/514-t-embed.t .......................... ok
t/515-t-cmd.t ............................ ok
t/516-t-clone.t .......................... ok
t/517-t-targetable.t ..................... ok
t/600-t-compat.t ......................... ok
All tests successful.
Files=27, Tests=265, 10 wallclock secs ( 0.19 usr +  0.14 sys =  0.33 CPU)
Result: PASS```

PS: FYI, I used `CCTYPE = MSVC100` with this SDK.