Using released 64 bits build environment from Platform SDK with Visual Studio 2005 beta 2

Par Gilles Vollant

info@winimage.com

 

You can read a french version of this article, and get more info on 64 bits computing section on Gilles Vollant's forum.

Introduction

Windows 64 bits exists in two platforms:

April 2005, Microsoft releases several software for Windows 64 bits:

 

A developer who wants to release quickly a 64 bits version, has only two solutions: using the platform SDK environment (without Visual Studio IDE), or using Visual C++, which is currently only a beta.

But the Platform SDK build environment (compiler, libraries, includes files...) can be used from Visual Studio 2005. There are two ways:

The procedure described below is compatible with both x64 and Itanium platform. It allows compiling unmanaged (without using .Net framework) C++ code. Warning: some libraries from Platform SDK are older than equivalent Visual C++ 2003 libraries (like MFC libraries). There is a Microsoft page and a KB article with more information.

There is also difference for runtime library "Multithreaded DLL" (see below)

The 64 bits compilers themselves from Platform SDK are at a Visual Studio 2005 version level. They support "Link code time generation" (or "Whole Program Optimisation") and "Profile-Guided Optimization".

You need to find the file devenv.exe. The default location is "X:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\devenv.com" (or "X:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.com" on 32 bits Windows). You can start devenv.exe with parameter "/?" to obtain parameters list.

 

Using Visual Studio 2005 IDE with Platform SDK

Just start Visual Studio 2005 (by just clicking on the icon), and take a look at VC++ directory (Tools / Options / Projects and solutions / VC++ Directories):

The executable directories for Win32 (32 bits) and x64 are different.

To use the compiler and build environment x64 from Platform SDK, start the Platform SDK command line:

 

You can now start Visual Studio 2005 and use the environment variable of Platform SDK for x64:

 

Take again a look at VC++ directory (Tools / Options / Projects and solutions / VC++ Directories):


The directories for "Plateform x64" are Platform SDK directories.

The Platform "Win32" gets the same value and CANNOT be used:

When Visual Studio 2005 is started with "/useenv" parameter, only the platform of the command line Platform SDK can be used.

 

Difference about DLL runtime library

With Visual C++, the runtime library can be called from a DLL. But the import library msvcrt.lib from Visual Studio 2005 and Platform SDK are different:

 

Automate building process with batch file

We can use a batch to automate building process. Start "devenv /?" to get the list of parameters used on this sample.

"K:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\devenv.exe" fdtray_vs8.sln /rebuild "ReleaseCrtDll|x64" /project fdtray_vs8 /useenv /out build_fdtray_x64ksdk.txt

type build_fdtray_x64ksdk.txt

 

 

By using the very good tools Dependecy Walker (this tool exists on all 32 and 64 bits platform of Windows, 32 and 64 bits, including the unreleased Windows 64 bits for Dec Alpha), we can verify that our executable is linked to msvrt.dll. If we compile with Visual Studio 2005 library, it is linked with msvcr80.dll.