There are a lot of posts around the topic how to compile for Windows 64-Bit with the VC2008 Express editions. The documentation is weak here and you find a lot of posts with questions around this topics. As I could not find any solution around this I started digging a bit deeper into the problem, to see what went wrong and how to fix it. Not sure if Microsoft officially supports this or prevents this intentionally, but there is a way to get a clean configuration with preserving all the nice things Visual Studio offers. Unfortunately it requires modifying the registry and copying some files. Hopefully Microsoft comes up with something better in the next version. While the full version of Visual Studio works flawless and as documented I struggled a couple of evenings to get it running with the Express version. Here are the details (I recommend reading first the full article before you try the modifications):
The Documentation
The basic instructions how to enable 64-Bit targets are here: http://msdn.microsoft.com/en-us/library/ms185328.aspx. You start the configuration manager to create an x64 Target in addition to Win32. For the Express version you first need to install the Windows SDK (former Platform SDK) and configure VC to use the installed SDK instead of its own SDK. There are many instructions around how to do this. Now the documentation says: On the Build menu, click Configuration Manager. 1.In the Active solution platform list, select the 64-bit platform for the solution to target. If the platform does not exist in the list, select New. 2.In the New Solution Platform dialog box, select the 64-bit platform for the solution to target. Note: If you create a new name for your configuration, you may have to modify the settings in the Project Designer to target the correct platform. 3.If you want to copy the settings from a current platform configuration, select the platform configuration to copy settings from, and click OK. But the issue is: if you use the Express edition you don’t see the x64 option in step 2. It simply does not exist. Also if you open Tools/Options and then go to Projects and Solutions / VC++ Directories you will find under platform only Win32 and not x64 (as in the full version). Here ends the documentation and there is no information available where Visual Studio gets this information from and how a platform can be added. The Solution The next step is to find out where VStudio gets the available platforms from. Open the registry editor (regedit.exe) and navigate to [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Visual Studio\9.0\VC\VC_OBJECTS_PLATFORM_INFO\]. Below this key all the available platforms are listed. You should find here two subkeys Win32 and Win64 (AMD64). The SDK installer creates these keys if it detects a Visual Studio. This works fine for the full version. The problem is that the Express version does not get the information from this path, but all its configuration is located in [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VCExpress]. So select VC_OBJECTS_PLATFORM_INFO in the registry editor and export this to a text file (.reg). Open this text file in a text editor (like Notepad) and replace all lines with brackets like this: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\VC\VC_OBJECTS_PLATFORM_INFO]to [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VCExpress\9.0\VC\VC_OBJECTS_PLATFORM_INFO] Double click the modified file and confirm to update the registry. However we are not done yet. This information contains only a class id and this information is also in the registry and needs to get moved. Navigate to: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\CLSID\ There are 4 class ids meaningful for 64-Bit compilation (I am not 100% sure if you really need them all).
{656d8763-2429-11d7-8bf6-00b0d03daa06}{656d8760-2429-11d7-8bf6-00b0d03daa06}{656d8763-2429-11d7-8bf6-00b0d03daa06}
{656d875f-2429-11d7-8bf6-00b0d03daa06}
Repeat the steps from above for each of these class ids (select the id in the registry editor, export to a .reg file and change there all lines having the […]. Replace the string VisualStudio with VcExpress. Save the modified file, double click and import it to the registry.
For each available platform VStudio needs to get the correct directories where the compilers, headers and libs are. You can see those in Tools/Options and then go to Projects and Solutions / VC++ Directories. So where do they come from? It seems that VStudio scans the directory $(InstallDir)\VC\vcpackages (where install dir is the installation directory, e.g. c:\program files\Microsoft Visual Studio 9.0). It seems that all files containing the extension „.config“ are used to import the directories for the various platforms. These are readable xml files. The name of the file is not meaningful but in the xml part there is a GUID making the back reference which platform it describes. The SDK installer therefore copies the file named AMD64.VCPlatform.config containing the appropriate information to this directory. However there is another subtle difference (for whatever reason…) between Visual Studio and Visual Studio Express. Whereas the full version scans for files named .config the express version scans for files ending with .Express.config. Therefore rename the file from AMD64.VCPlatform.config to AMD64.VCPlatform.Express.config. Now open again Visual Studio (note that each change requires a restart of Visual Studio Express!) and check again the platforms in Tools/Options /Projects and Solutions / VC++ Directories. In the platform box you should now see two options (Win 32 and x64). Select x64 and check that there is a list of suitable directories in place. If x64 does not appear something went wrong in the first step. If x64 is available but the list of directories is empty something is wrong with the renaming of the .config file. If everything is fine you have the platform properly configured now and can proceed with the Configuration Manager to add the new platform to your project (for details see MSDN documentation about 64-Bit programming, link is above).
Note 1: Be aware that there exist two 64 bit compilers. One which is itself a 64 bit program and another one is a cross compiler running at 32-Bit but producing 64-bit object files. Be sure that you don’t take the wrong one (normally always the cross compiler is used).
Note 2: The same procedure should work with other platforms like IA64 for Itanium with of course different file names and GUIDs. The structure is the same, the DLL is named VCProjectIA64Platform.dll and the configuration file is Itanium.VCPlatform.Express.config. However I did not try this.
VC2008 Express installed on a 64-bit operating system
All instructions so far have been valid when Visual C++ is installed on a 32-Bit operating system. If it is installed on a 64-Bit operating system there are some more pitfalls (and presumably bugs in the SDK installer). At first there is a special branch in the registry for 32-Bit applications on 64-Bit operating system. So all paths in the registry mentioned above have to be changed from: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VCExpress\9.0\ ...] to [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\…} The second change is an even more subtle bug: The 64-Bit C++ compiler exists in two flavors. One is a cross compiler running on 32-Bit (installed in …\VC\bin\x86_amd64) and the other is 64-Bit application (installed in …\VC\bin\amd64). If SDK installer detects a 64-Bit operating system it copies the 64-Bit version of the VCProjectAMD64Platform.dll to the …\VC\vcpackages directory. However this makes absolutely no sense since the VC200 Express is always (at the time of this writing) a 32-bit application. So you have to manually copy VCProjectAMD64Platform.dll from $($VCDIR)\VC\bin\x86_amd64 to ($VCDIR)\VC\vcpackages. $(VCDIR) means in this case the directory where your VC2008 is installed, e.g. c:\Program Files\Microsoft Visual Studio 9.0. There is no easy way to check whether you have the 32-Bit or the 64-Bit version of the DLL installed. Both have the same name and version. The easiest way to differentiate them is to look at the file size: The 32-Bit has 283KB the 64-Bit version has 370KB. Using VC2008Express on 64-Bit system has the advantage that you can debug your applications in the same environment where you compiled them.
Conclusion
I have no clue if this is a bug in the SDK installer or if this limitation is intended by Microsoft. To me it seems that someone made a decision like „Oh let’s separate Express version from full version completely by just taking a different branch in the registry“ But the impact of such a decision was a subtle change in the interface that no one has considered and/or was not very well communicated between the different teams. …like so often in software development. Yes the fix is nasty and changes in the registry like this are a bit dangerous too but once done it works really nice! Let’s hope that Microsoft fixes this in the next version of the SDK and gives us all the more and more important benefit of 64-Bit in the Express editions.
Addendum
Here is some additional information from reader contributions. Thanks to everyone who provided feedback and helped to improve this.
Missing VCProjectAMD64Platform.dll:
It seems that under some circumstances the 32-Bit version of this DLL does not get installed if you are on a 64-Bit OS. So you won’t find it in $($VCDIR)\VC\bin\x86_amd64. In this case you either have to copy it from an installation on a 32-Bit OS or extract it from the SDK installer medium. The DLL is located in the ISO distribution’s \Setup dir in the vc_stdx86.cab. It starts with FL_VCProjectAMD64Platform…if you rename it to the proper name it should work. Thanks Dustin for this helpful hint!
Xia Wei provided a helpful script that automates this tweaking. I did not try this myself but after a couple of positive reader comments it’s definitely worth mentioning it here. Download is available here: http://suma.soulogic.com/dl/VCE64BIT.zip
Filed under: C++, Development | 31 Comments
Tags: C++, Development, IDE, VC2008, VC2008 Express, Visual Studio
Thank you. I was able to get it working.
You might want to suggest reading the entire post before starting. I did all the changes and then had to move them all to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node.
Thanks again, it works!
Many thanks for your complete and accurate instructions, it works a treat.
I would second Greg’s comment that the entire post be read before making any changes. Fortunately I did that.
Thanks again.
Thanks for providing feedback! I added the hint to read the full article first.
I followed the instructions but there was no VCProjectAMD64Platform.dll in the …\VC\bin\x86_amd64 directory! There is only one in the ..\VC\bin\amd64 and it is of size 370kb. After following the instructions minus copying the non-existance cross-compiler, I still don’t have x64 target option. Where can one find the 32bit dll?
Can this depend on your installation options when installing the express edition? Or maybe if the Service Pack 1 is installed or not?
Thank you for your excellent article.
I also have the same problem as Steve: the 32-bit
version of VCProjectAMD64Platform.dll is missing.
Some details. Development environment:
Windows Server 2008 x64
Windows SDK for Windows Server 2008
Visual Studio Express 2008 SP1
Presumably, if I were using a 32-bit OS, the 32-bit
version of VCProjectAMD64Platform.dll would have
been installed. I used the net installer, rather than
the ISO image. I will download the ISO image later
and see if the 32-bit dll is contained within it.
Does in the case where VCProjectAMD64Platform.dll is missing the directory $($VCDIR)\VC\bin\x86_amd64 exist at all? If yes what files are in this directory? Is only this DLL missing or the complete compiler? Can this DLL perhaps be found somewhere in the Windows SDK? I think the compiler gets there installed too.
Yes, the directory does exist. Its contents:
$($VCDIR)\VC\bin\x86_amd64\1033
$($VCDIR)\VC\bin\x86_amd64\1033\clui.dll
$($VCDIR)\VC\bin\x86_amd64\1033\linkui.dll
$($VCDIR)\VC\bin\x86_amd64\c1.dll
$($VCDIR)\VC\bin\x86_amd64\c1xx.dll
$($VCDIR)\VC\bin\x86_amd64\c2.dll
$($VCDIR)\VC\bin\x86_amd64\cl.exe
$($VCDIR)\VC\bin\x86_amd64\cl.exe.config
$($VCDIR)\VC\bin\x86_amd64\dumpbin.exe
$($VCDIR)\VC\bin\x86_amd64\editbin.exe
$($VCDIR)\VC\bin\x86_amd64\lib.exe
$($VCDIR)\VC\bin\x86_amd64\link.exe
$($VCDIR)\VC\bin\x86_amd64\link.exe.config
$($VCDIR)\VC\bin\x86_amd64\ml64.exe
I’ve searched the whole filesystem. The file ‘VCProjectAMD64Platform.dll’
has two bit-for-bit identical copies. One is in $($VCDIR)\VC\bin\amd64.
The other is in $($VCDIR)\VC\vcpackages.
This is strange. The only difference I can see is that you installed on a server OS. For my tests I used XP 32-Bit and either Windows 7 Beta 64-Bit or XP 64 Bit (can’t remember, it was on a temporary virtual machine). All these are no server operating systems. This really should not make any difference but who knows…. Another potential cause might be whether you first install SDK and then VC Express or the other way round. I installed VC Express first and then the SDK. It might be that the SDK installer needs to detect an existing VC to install this DLL. The compiler from the SDK can be used from command line without a VC. And without a VC it would make no sense to install this DLL…
Ok I’ve found a solution to the missing 32-bit VCProjectAMD64Platform.dll.
All along I used the VS Express 2008 with SP1 and Windows Server 2008 SDK iso images burned on dvds for installation. I installed the VS Express first followed by the SDK. The above mentioned 32-bit dll was missing when I installed on Vista 64-bit OS.
One has to wonder what would happen if the whole thing was installed on a 32-bit Win XP OS. There is no way the 64-bit dll would be installed on a 32-bit Win XP OS, is there? So I went ahead and did just that. Voila lo and behold, the 32-bit VCProjectAMD64Platform.dll with the size of 283KB appeared in the vcpackages directory. The 64-bit and the IA64 versions are no where in sight but they don’t really matter. Now one simply copies the 32-bit dll over into the Vista 64-bit OS to complete the journey to open the possibility of compiling 64-bit applications using VS Express 2008.
The bottom line is if all the ingredients are there, the steps in this blog absolutely work. Beautiful and thank you!
This is an awesome article, thanks!
To Rudy, Steve and anyone else that had the missing 32bit VCProjectAMD64Platform.dll problem — if you don’t wanna fire up a virtual machine and reinstall the whole SDK mess, the dll is located in the ISO distribution’s \Setup dir in the vc_stdx86.cab. It starts with FL_VCProjectAMD64Platform…if you rename it to the proper name it works.
Hi,
Thanks for the clear documentation.
I also want to thank the teams at Microsoft for saving me money in this economy. I no longer need to get haircuts because I have pulled out all my hair.
-Steve
Thanks for the great article!
I created some simple batch files to automatically enable 64bit programming in VC express.
Both AMD64 and IA64 are included.
Download it here: http://suma.soulogic.com/dl/VCE64BIT.zip
Hope this will be also useful.
Thank you so much for this page! After a bit of work, it looks like I am up and running for Win64 development with 2008 Express (on Win7 x64 Beta). Thanks again!
Tyler
Awesome Article. Thank you everyone.
Here’s my suggestion to this pot:
To see if the correct compiler is running, select suppress startup banners to no. This will tell you if the correct compiler is compiling the files.
Another suggestion, i don’t know why we need the windows sdk at all (except to create those visual studio registry keys, were they created by the sdk?), the latest vc express 2008 seems to contain everything.
Thank you so much Jens and Xia Wei!
I use VC++ express for 64 Bit XSI and messiah:studio shader compiling for several years now, but so far I had to set all the entries by hand each time and never got it right the first time – now it is one click of a .bat
Superb!!!
Thank you!
Hey,
what if I want to install all this on an intel 64 bit machine?
Thanks very much. Couple of tips:
1. Use the scripts that Xia posted – there is a script for 32 and 64 bit O/Ses and the 32 bit versions of the libraries are included so you don’t need to grab them from the SDK.
2. If you are on Vista make sure you run the command prompt as administrator when running the script. From the start menu, type cmd in the Start Search textbox, right click on the Command Shell and “Run as administrator”. Note some places say you can Ctrl-Shift-Enter to do that instead of right clicking but that doesn’t work for me.
Andy.
P.S. To Steven – yup, this is for Intel x64 too. AMD got there first!
Hmm, no love for me. I wonder what I might be doing wrong. Tried running Xai’s script. It complained that some of the config files were missing:
C:\Documents and Settings\Dave\Desktop\VCE64BIT>copy “C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\AMD64.VCPlatform.config” “C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\AMD64.VCPlatform.Express.config”
The system cannot find the file specified.
and similar messages for the files
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\Itanium.VCPlatform.config”
I do indeed have the following SDKs installed:
Microsoft .NET Framework 2.0 SDK – ENU
Microsoft Windows SDK for Visual Studio 2008
Microsoft Windows SDK for Windows Server 2008
Now, when I try to follow the instructions manually, I get to the part where I am supposed to edit the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Visual Studio\9.0\VC\VC_OBJECTS_PLATFORM_INFO\
But I do not have that branch in the registry. It goes as far as the 9.0 node, but no VC underneath it.
Actually, I wonder if Xai’s regedit /s commands are working properly. His VC_OBJECTS_PLATFORM_INFO.reg file looks like it should build the right nodes in the registry, but it is apparently not.
Any ideas?
Dave – that looks like you don’t have VC installed for Visual Studio Express? You need that as well as the Windows SDK.
Andy.
Nope, I do have it. It’s listed in the Add/Remove Programs thingy as
Microsoft Visual C++ 2008 Express Edition with SP1 – ENU
Thanks, it works like a charm (on Vista x64)! I thought to write some little script, but then read Xia’s post… that saves me quite a bit of time
Of course I didn’t install VC++ and the Windows SDK at C:\, that would make things too easy, but all I needed was a simple find and replace.
@Dave; could it be that you didn’t install VC++ Express & the SDK on the default directory?
Works great for me, thank you very much!
@Dave
Today I installed VC2008 Express and WIN7 RTM SDK on a clean x86 machine, and encountered a similar problem. It seems the latest WIN7 SDK does not install any x64/IA64 tools or libraries into VC installation folder.
WIN7 RTM SDK have 3 releases which support x86, x64, and ia64 ( http://blogs.msdn.com/windowssdk/archive/2009/08/10/troubleshooting-windows-7-sdk-download-install.aspx ). The patch I posted above only works for x64 SDK on x64 machine. If you need to get it work on x86 macine, it is still possible but you need to do it manually again:
In VC installation folder, copy over following folders and files
1. bin\amd64, ia64, x86_amd64, x86_ia64
2. lib\amd64, ia64
3. vcpackages\VCProjectAMD64Platform.dll, VCProjectIA64Platform.dll, AMD64.VCPlatform.Express.config, Itanium.VCPlatform.Express.config
from a well patched x64 machine.
I’ll try to automate this later.
Just a quick note, If, after installing win7 64bit and the win7 sdk the setup_x64.bat file doesn’t seem to be working, Turn off UAC (User Account Control) completely, then reboot. Now that UAC is turned off, the setup_x64.bat should work properly.