Windows 7 Build Setup

From Cryptohaze Project Wiki
Revision as of 01:39, 28 June 2012 by Peefourtee (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This guide goes from a stock Windows 7 box to a box capable of doing Cryptohaze dev, both CUDA and OpenCL. It assumes the same system used for Linux, with an ATI card driving the display, and one or more other GPUs to include nVidia GPUs present in the system.

Contents

Basic Setup of All Required Dependencies

Install Windows 7 64-bit and update it. This should take a bunch of reboots & a good long while, annoyingly.

When done, you'll want to download the following items:

  • ATI Catalyst drivers for Windows (currently 12.4)
  • ATI OpenCL SDK for Windows (currently 2.6)
  • nVidia GPU driver for Windows (currently the 4.2 devdriver)
  • nVidia CUDA toolkit for Windows (currently 4.2)
  • nVidia CUDA SDK/code samples for Windows (currently, surprise, 4.2!)

Install the ATI Driver

This should be easier than on Linux.

Install the ATI driver.

I did a custom install to make sure absolutely everything got installed.

Install the nVidia driver

Install the nVidia driver next.

I did a custom install with the clean install option, despite not having former nVidia drivers around.

Curse

Now, you should have both devices working. Wasn't that easy? Why do I code on Linux again as a primary OS? This was painless!

Install the SDKs and toolkits

For all the downloads above, install the proper SDK/toolkit/etc. Pick your locations, though I'd suggest putting the CUDA SDK in your home directory, not in the weird default location (this matches Linux, which puts it in ~/NVIDIA_GPU_Computing_SDK or such). You don't technically have to install the AMD APP SDK if you don't want to - but it's nice to have the kernel analyzer available.

Download VS 2010 and Windows SDK 7.1

(I'm doing this for the first time, so... apologies if steps are slightly out of order)

Step 1 is to download Visual Studio Express 2010.

http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express is a good place to start. Download the installer, and run it (vc_web.exe). You don't need the SQL 2008 additional download.

You'll also need the Windows SDK (currently 7.1) for the 64-bit compilers - unless you want to do 32-bit only builds, which are not fully supported...

http://www.microsoft.com/en-us/download/details.aspx?id=8279 is a good starting point to download this - you'll want to run winsdk_web.exe when downloaded!

The default install here is just fine.

Finally, download and install the Windows SDK 7.1 SP1 update: http://www.microsoft.com/en-us/download/details.aspx?id=4422

And, to fix missing header file, VS2010 SP1. http://www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=75568aa6-8107-475d-948a-ef22627e57a5

And, bloody hell, fix the missing batch file for VS2010 Express. This is getting downright absurd.

In C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64, create "vcvars64.bat" with the following (you will need to be running as administrator):

CALL setenv /x64

SVN Client

You'll need a SVN client to check out the Cryptohaze tools. I use RapidSVN on Windows - http://rapidsvn.tigris.org/ Download & install the latest version.

To check out the repository:

It'll take a while, and you should get the source downloaded nicely into your home dir.

Great - now you have the source. Unfortunately, you're missing some prerequisites... like Boost.

Install Boost

Download Boost from boost.org - I normally download the zip version on Windows. Anything newer than 1.47 *should* work. I'd suggest extracting it with 7zip or winzip or something - it takes FOREVER with the stock Windows zip extractor!

Start up your VS command shell - Start->All Programs->MS VS Express->Command Prompt

Change to the directory you've extracted boost in - perhaps "cd \Users\[your username]\Downloads\boost_1_49_0" ?

Run "bootstrap.bat" to build the builder.

If it completes, you should have a "b2.exe" in the directory now. Awesome!

Let's start with the 64-bit libraries first. Note: if you're building these with VS2010 Express, look at the bugs/glitches/troubleshooting note before continuing.

b2.exe --toolset=msvc-10.0 --build-type=complete --without-mpi --without-python architecture=x86 address-model=64 stage

If you have a multicore box (I know you do!), you can use "-j#" for the number of threads to run in parallel - usually 1.5x your number of cores.

Now is a time for a walk/movie/nap/sex with your {girlfriend,fiancee,wife,boyfriend,whatever}.

Once this is done, move them to the x64 subdirectory.

cd stage\lib
mkdir x64
move * x64
cd ..\..

Now, make the 32-bit libraries.

b2.exe --toolset=msvc-10.0 --build-type=complete --without-mpi --without-python stage

And, move them to the x86 dir.

cd stage\lib
mkdir x86
move *.lib x86
move *.dll x86
cd ..\..

Great - boost has been compiled.

Let's move boost to somewhere a bit saner - perhaps C:\boost_1_49_0 ?

move boost_1_49_0 c:\

Last but not least, create an environment variable in windows "BOOST_ROOT" with a value of your boost path, from this example c:\boost_1_49_0. Boost is ready to go!

Install cmake

http://www.cmake.org/cmake/resources/software.html - go, download, install.

Install libcurl

In the dependencies\ folder you can find curl-7.26.0.tar.gz. Extract it to dependencies\curl-7.26.0.

In VS2010, open dependencies\curl-7.25.0\lib\libcurl.sln and let it convert it. By default it's configured to build the 32-bit library which probably isn't what you want. To build a 64-bit library, click the "Win32" dropdown, go to Configuration Manager, and under Active Solution Platform, select "new". Create a new x64 solution, copying from the existing win32 settings. While in the Configuration Manager, change the Active configuration to release as well. You should now be able to build a 64-bit version of libcurl that will be automatically detected by cmake.

Note: if you decide to build curl elsewhere on your system you must remember to modify the cmake variables CURL_INCLUDE_DIRS and CURL_LIBRARY_DIR.

Install protobuf

You'll need Google Protobuf to build the new multiforcer. Like curl, go into dependencies\ and extract protobuf-2.4.1.tar.bz2 to dependencies\protobuf-2.4.1. From here open up dependencies\protobuf-2.4.1\vsprojects\libprotobuf.vcproj and let VS convert it to the new format.

By default it's configured to produce 32 bit libraries which you'll probably want to change. Just like curl, go into configuration manager and add a new active solution platform of x64, copying from win32 and checking the create new project platforms checkbox. Change the Active configuration to release, click OK and build that sucker. It the produced lib will automatically be used by cmake.

Note: if you build protobuf anywhere else than dependencies\protobuf-2.4.1 cmake will fail to configure. Update the PROTOBUF_SRC_ROOT_FOLDER to correspond to the root directory of the extract protobuf source and reconfigure in cmake.

Using CMake to Generate VS2010 Solutions

First if you haven't gone through the first section and installed all required dependencies, do that.

  1. Open up CMake (cmake-gui)
  2. Set "Where is the source code:" to be the directory that cryptohaze-combined was checked out to
  3. Set "Where to build the binaries:" to be any directory that is NOT cryptohaze-combined. I recommend making a folder inside cryptohaze-combined called build-cmake and selecting it but it could be anywhere, such as your desktop.
  4. Click configure. In the box that pops up select Visual Studio 10 Win64 for 64 bit builds. If you're building 32, select Visual Studio 10. Note: if you get errors about detecting libraries, refer to the troubleshooting section of the windows dev wiki.
  5. Click configure again to commit the red-highlighted entries to the cmake cache and then click Generate to create the VS solution files in the build-cmake folder.

The build-cmake\ folder now contains VS 2010 solution files for all the cryptohaze tools with include/lib paths setup based on your dev environment. Open up build-cmake\cryptohaze.sln and you'll see bunch of projects in the solution explorer. The ch_* projects are all libraries created out of the cryptohaze source and linked in for multiple tools. To exclude building some tools, right click the tool name and go down to Unload Project. This is really useful for speeding up builds since you probably don't care about building Cryptohaze-Multiforcer when you really want New-Multiforcer, or don't care about the GRT tools.

Alternatively you can navigate the subdirectories of build-cmake\src and find the project files for only the targets you want to build and open the vcxproj file. New-Multiforcer lives in build-cmake\src\MFN_Common, GRT tools in build-cmake\src\GRT_Common and Cryptohaze-Multiforcer in build-cmake\src\Multiforcer_Common

After selecting the projects you want to build, set VS to build the release binaries and build them. The first time you build debug or release after generating the projects there might be some dialog boxes popping up asking if you want to stop the build to reload the projects. Click cancel (VS has problems stopping nvcc mid-build) on these and at the end of the build VS will prompt you to reload the projects where you can safely do it.

Once everything has been successfully build, right click on the INSTALL project and click build. This will copy all binaries/kernels/charsets/test hashes/etc to build-cmake\bin for you.

Bugs/Glitches/Troubleshooting

Building 64 bit Boost libraries

VS2010 Express won't build 64-bit Boost by default. You need to run a setenv command.

If you get "nvcc fatal: Visual Studio Configuration File '(null)' could not be found..." errors: Create vcvars64.bat with the line "CALL setenv /x64"

CMake Configuration Errors

CMake relies on some environment variables to detect the root directory of a project's source. Here is a list of environment variables that are being checked:

  • CUDA_PATH - path to the NVIDIA GPU Computing Toolkit, default C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\
  • NVSDKCOMPUTE_ROOT - C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.2\
  • BOOST_ROOT - path to root boost folder, ex c:\Boost_1_49_0\

error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' ...

This error happens when attempting to link some of the libraries built in debug mode against cryptohaze projects being build in release mode or vice versa. To fix it ensure that whatever build mode you're using for cryptohaze matches the build mode that all the libraries have been built with.

error LNK1104: cannot open file 'ASDF.lib'

If you've followed the steps on the wiki for setting up the project then this error occurs when one of the targets was build targeting the wrong platform (build 32bit instead of 64 bit libs or vice versa). If you're building boost, take note of the building 64 bit boost libraries info in this section. Also, make sure you've moved the boost libs into their stage/lib/x86 or stage/lib/x64 folder as instructions stated.

If it's libcurl or libprotobuf, go redo the instructions for building those libraries but make sure you go into configuration manager and add a 64 bit target.

If you're using non-standard directories then you're on your own to verify that the additional link directories and libraries were correctly configured in VS. This can be done by right clicking the project causing problems and going to properties, looking at the Linker->General->Additional Library Directories and Linker->Input->Additional Dependendencies entries.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox