From BlenderWiki
Building x64 targets with Visual C++ 2008 Express
It's possible to build 64 bit versions of Blender using Visual C++ express from microsoft, and windows 7 x64 editions (Windows Vista x64 requires another toolchain and have some aditional complications that i won't write here), but setting up the compiller and environment is not exactly easy. As a fair warning, you need to have some experience using and abusing the registry and there's the possibility of turning windows unuseable if you do something wrong with the registry of windows. You have been warned.
Also, notice that this setup is not sanctioned by the official developers of Blender, so reporting bugs errors with binaries produced by this toolchain is discouraged. Just check the official binaries produced by the Blender Foundation and check bugs aganist them.
Basic Downloads and requirements
Visual C++ 2008 Express edition don't support oficially 64-bit targets, but if you install it on a 64-bit Operating system, you can configure it to produce 64-bit targets. YOU CAN'T BUILD OR GET THE EXPRESS 64-BIT TOOLCHAIN ON A WINDOWS 32-BIT OPERATING SYSTEM!
So, if you got Windows 7 x64 edition, 5-6 GB of Hard Disk Space to waste, and feel adventurous, then let's begin with the fun.
1st Step: Download and install the required files.
1.) .Net Framework: At the time of writing, .net framework 4 is out. Windows 7 comes with .net framework 3.5 installed by default, but don't hurt to install the updated version. You should install it from Microsoft Update, but you can download it separately from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9cfb2d51-5ff4-4491-b0e5-b386f32c0992&displaylang=en (web installer).
2.) Microsoft Visual C++ 2008 Express: You can get it from http://www.microsoft.com/express/Downloads/ and select the Visual Studio 2008 Express tab; this will guide you to the download page, and to the web installer. You'll need the software, compillers, headers and libraries. The documentation adds a big download time and size so you can safely skip that.
3.) Windows 7 SDK: You can get it here http://www.microsoft.com/downloads/en/details.aspx?familyid=C17BA869-9671-4330-A63E-1FD44E0E2505&displaylang=en , you just need the web installer and as minimum select the tools, compillers and headers (You don't need the documentation, is optional and is a very big download). Don't use the SDK that contains the .NET framework 4: Won't work properly with this setup.
OK, you have done the easy and safe part. You can build 32-bit Blender binaries right now following the instructions of the wiki. If you still insists on 64-bit with VC++ 2008 express, continue reading.
Setting up The Toolchain
2nd Step: Configure the compiller and system to produce 64-bit binaries.
Warning
You need to edit and rename some files to make things work. UAC can/will prevent you to make changes without warning or at least issues a warning about modifying system files. I recomend to DISABLE UAC until you finish to setup the environment to produce 64-bit binaries, otherwise you can/will have problems, because you need to run/modify some files as Administrator. You can enable again once you have finished the risky parts.
|
1.) Go to *drive*:\*Program Files Folder* (x86)\Microsoft Visual Studio 9.0\VC\vcpackages and RENAME the file "AMD64.VCPlatform.Config" to "AMD64.VCPlatform.Express.Config" (If you are doing this from the GUI, probably won't see the extensions, since windows by default hides the extensions from known file types. You can go to Organize -> Folder and search options -> go to the "show" tab and look for "Hide extensions of files..." option and uncheck it, click OK and you are set)
2.) Go to *drive*:\*Program Files Folder* (x86)\Microsoft Visual Studio 9.0\VC\bin and COPY the file "vcvars64.bat" to *drive*:\*Program Files Folder* (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64 and RENAME it to "vcvarsamd64.bat"
3.) Open the registry editor (regedit.exe) and navigate to [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\VC\VC_OBJECTS_PLATFORM_INFO], and there you will see some Keys. You need to export the "Win64 (AMD64)" Keys in REGEDIT4/NT4 .reg format. (Select the "Win64 (AMD64)" key, and right click over it to open a menu: Select "Export" and in the save dialog, in the file type, choose "win9x/NT4 (REGEDIT4)" type file (.reg), you need to give the file a name)
4.) Open the file you saved with notepad, and CHANGE all apperances of "VisualStudio" to "VCExpress". As an example, the original file should be something similar to:
REGEDIT4 [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\VC\VC_OBJECTS_PLATFORM_INFO\Win64 (AMD64)] @="{656d8763-2429-11d7-8bf6-00b0d03daa06}" [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\VC\VC_OBJECTS_PLATFORM_INFO\Win64 (AMD64)\ToolDefaultExtensionLists] "VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c" "VCLinkerTool"="*.obj;*.res;*.lib;*.rsc" "VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc" "VCMIDLTool"="*.idl;*.odl" "VCCustomBuildTool"="*.bat" "VCResourceCompilerTool"="*.rc" "VCPreBuildEventTool"="*.bat" "VCPreLinkEventTool"="*.bat" "VCPostBuildEventTool"="*.bat" "VCBscMakeTool"="*.sbr" "VCNMakeTool"="" "VCWebServiceProxyGeneratorTool"="*.sdl;*.wsdl" "VCWebDeploymentTool"="" "VCALinkTool"="*.resources" "VCManagedResourceCompilerTool"="*.resx"
And should be edited so the final file should look similar to:
REGEDIT4 [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\VC\VC_OBJECTS_PLATFORM_INFO\Win64 (AMD64)] @="{656d8763-2429-11d7-8bf6-00b0d03daa06}" [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\VC\VC_OBJECTS_PLATFORM_INFO\Win64 (AMD64)\ToolDefaultExtensionLists] "VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c" "VCLinkerTool"="*.obj;*.res;*.lib;*.rsc" "VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc" "VCMIDLTool"="*.idl;*.odl" "VCCustomBuildTool"="*.bat" "VCResourceCompilerTool"="*.rc" "VCPreBuildEventTool"="*.bat" "VCPreLinkEventTool"="*.bat" "VCPostBuildEventTool"="*.bat" "VCBscMakeTool"="*.sbr" "VCNMakeTool"="" "VCWebServiceProxyGeneratorTool"="*.sdl;*.wsdl" "VCWebDeploymentTool"="" "VCALinkTool"="*.resources" "VCManagedResourceCompilerTool"="*.resx"
Save the file and exit the editor.
5.) Import the edited file (double click the file) to the registry. A window will appear to confirm the operation. Just click OK.
6.) Check in the registry for the changes done. Open the registry editor and go to [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\VC\VC_OBJECTS_PLATFORM_INFO] and you should now have a key called "Win64 (AMD64)". If you don't, stop here and check what you have done wrong (Probably you didn't disable UAC or you are not running with administrative privileges. You need both to be able to edit the registry and you should stop now and fix that before trying again and continue)
7.) If everything goes OK, you now need to repeat the process to 4 more keys. Open the registry editor and go to [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\CLSID]. You need to repeat the process described in steps 3-5 for the following keys:
{656d8763-2429-11d7-8bf6-00b0d03daa06}
{656d8760-2429-11d7-8bf6-00b0d03daa06}
{656d8766-2429-11d7-8bf6-00b0d03daa06}
{656d875f-2429-11d7-8bf6-00b0d03daa06}
After that, you need to check the registry in the location [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\CLSID] for the keys above, so everything goes OK.
That is, the compiller should be configured and the headers and libraries used to compilling Blender X64 should be ready. But there's some final steps to do before we can use it.
Setting up the headers and libraries
Open the Windows 7 SDK CMD shell located in "start -> Programs -> Microsoft Windows SDK v7.0 -> CMD Shell" and in the CMD window write the following:
CD setup WindowsSdkVer.exe -version:v7.0
At this point, a new window will appear and confirm that "The Windows SDK Configuration Tool has succesfully set Windows SDK version 7.0 as the current version for Visual Studio 2008". Just press any key to close it. (Don't try to use the GUI version of the SDK Configuration tool. Won't work with VC++ express edition.)
At this point, you can now reenable UAC if you wish.
Final Setup
Now we need to create a shortcut that alows us to use a x64 console window with the proper environment to build Blender. Visual C++ 2008 Express doesn't come with one, so we need to create one. I will create a shortcut in the desktop, but you can create it where you need/want it.
1.) Right Click in the desktop and in the menu choose New -> Shortcut...
2.) In the location, put the following:
%comspec% /k "*drive*:\*Program Files Folder* (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" amd64
Note: Replace *drive* with the corresponding unit letter (usually C) and *Program Files Folder* with the name of the folder you installed visual studio 2008 express (Typically "Program Files (x86)"
Then click "Next".
3.) In the description, put whatever you want. As an example i put "System Symbol for Visual Studio x64", then click "Finish".
4.) OPTIONAL: Our Shortcut is created and almost ready to use, but as an optional step, you can define where the CMD shell will star initially: You can create a folder (e.g.: c:\BlenderSVN) and then right on the shotcut we created in step 3, then choose "properties". Then in the "start in" box, put "C:\BlenderSVN" and voila, the next time you start the shell environment you will automatically start in c:\BlenderSVN
Now we got our environment ready to download the sources to build a 64-bit Blender binary. But once we downloaded the sources, we need to do a small hack to make this work.
Hacking SCONS to do the job
(a.k.a. "hacking SCONS to do the wrong thing")
Go to back to the build wiki and follow the instructions to get the sources from SVN, get back here after you got the sources. DON'T TRY TO COMPILE YET!
Ok. By default the scons system implemented in Blender checks for the compiller to use and the possible architectures used for compilling. We need to edit one file to remove the limitation that prevents using VC++ 2008 Express to generate a x64 binary under scons. I'll asume you followed the wiki and put the sources in C:\BlenderSVN:
1.) Go to C:\BlenderSVN\blender\scons\scons-local-1.2.0.d20090223\SCons\Tool\MSCommon and edit the "vs.py" file with wordpad (doesn't work with notepad) or any editor that supports the unix EOL style (notepad++ works fine). (Note: the scons-local-1.2.0.d20090223 name may vary!!)
2.) Find the "# Visual C++ 2008 Express Edition" setup. Just make a search with "# Visual C++ 2008 Express Edition" (if you are using notepad++, look around the lines 223-236 at time of writing).
3.) Look for the "supported_arch" tag: in the original file only you have the "x86" option, since by default VC++ 2008 express doesn't support x64 targets. But since we already setup the toolchain to produce x64 targets, this limitation doesn't apply anymore, so just change the line to:
supported_arch=['x86','amd64'],
and you're set. Save and close the editor.
You are now ready to compile and to build Blender 64-bit for windows using VC++2008 Express. Just follow the rest of the Building Blender for windows Wiki, and you shouldn't have any problems compilling Blender for 64-bit targets.
Have a nice day.