Par Gilles Vollant
You can read a french version of this article, and get more info on 64 bits computing section on Gilles Vollant's forum.
Windows 64 bits exists in two platforms:
Since 2001, on Intel Itanium : this very expensive processor is very scalable (for server with a lot of processors)
Since April 2005, for processor with x64 instruction set (64 bits extended), also called AMD64 or Intel EM64T. This instruction set is a 64 bits evolution of the well known 32 bits instruction set used by Intel Pentium and AMD Athlon (like 80386 instruction set, which was a 32 bits evolution of the 80286 instruction set), and it preserves compatibility. This instruction set is implemented on Amd Athlon 64, Opteron, and latest Intel Pentium 4 (like series 6xx) and Xeon "nocona". It'll also be implemented on future cpu from AMD and Intel.
April 2005, Microsoft releases several software for Windows 64 bits:
Windows Server 2003 SP1 x64 Edition (A 180 days trial software can be downloaded), Windows Server 2003 SP1 for Itanium and Windows XP for x64 (an evaluation CD can be ordered, or upgrade from Windows XP 32 OEM). All these versions of Windows are RTM (release to manufacturing, final code). Subscribers of MSDN download can get them.
Windows Server 2003 SP1 Platform SDK (you can download three installation packages: Web, Full Download, et image Iso). This free SDK contains full build environment, including two 64 bits compilers for x64 and Itanium. These compilers are cross tools and can be used on 32 bits or 64 bits computer. The 32 bits target compiler is not included (a free 32 bits Microsoft compiler is included on Visual C++ toolkit 2003).
Windows Server 2003 SP1 DDK, to build device drivers. It can be downloaded on MSDN Download, and can be ordered (for a very low price, like $25).
Visual Studio 2005 beta 2. It can be download on MSDN download, and a free evaluation can be ordered.
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:
modify manually the Visual C++ directories, used by Visual Studio to find files used by building process (see Tools / Options / Projects and solutions / VC++ Directories). This is a long task, which replace the standard Visual Studio directories.
A better way: uses option "/useenv" of devenv.exe, which is "Use PATH, INCLUDE, LIBPATH, and LIB environment variables instead of IDE paths for VC++ builds.".
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.
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.
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:
Under Visual Studio 2005 environment, msvcrt.lib contains a reference to msvcr80.dll (so you need to redistribute this DLL with your application), and contains the function called by "Buffer security check"
With Platform SDK, msvcrt.lib contains a reference to msvcrt.dll (a version of this DLL is installed by Windows itself) and contains no function used by "Buffer security check". So you need to add manually bufferoverflowu.lib in linker option (or to disable "Buffer security check", but this is not the most secure way).
We can use a batch to automate building process. Start "devenv /?" to get the list of parameters used on this sample.
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.