Building+OpenCV+yourself+on+Windows+7+x64+with+OpenCV+2.4.5+and+CUDA+5.0

//Since OpenCV 2.4.4, GPU prebuilt binaries aren't downloadable anymore from the main OpenCV website.//

In order to be able to actually use the GPU functionality however, the **core module** of OpenCV has to be built with GPU support. This guide will give directions on how to do this on a **Windows 7 x64 bit** machine using the current stable OpenCV release (**2.4.5** - branch of GIT repository) in combination with latest **CUDA 5.0** version and latest **TBB 4.1** version. Everything was built using **Visual Studio 2010**.

You should follow the next steps sequentially in order to guarantee succesful result.

__**STEP 0: INSTALLATION OF BASIC SOFTWARE**__

Before building openCV in Windows, you need to have all the necessary software preinstalled.
 * 1) Make sure you have the Visual Studio 2010 environment installed.
 * 2) Download and install CMAKE for Windows.
 * 3) Install a GIT client. For this you first need to download and install msysgit. After that install some GIT client software, like TortoiseGIT.
 * 4) Download the latest TBB version (here 4.1.3) from the official intel website.
 * 5) Download the latest CUDA version (here 5.0) from the official nvidea website.

Create some folders that are needed for processing
 * 1) Folder for OpenCV source code **C:/opencv_source/**
 * 2) Folder for OpenCV complete built **C:/opencv_built/**

Use the GIT software to retrieve the latest stable OpenCV version. Go to your **C:/ drive** and right-click on the **opencv_source** folder. Select the **'Git Clone'** option. Make sure to select the desired branch and add 2.4 for now, which is the current stable released branch.

//If you prefer, you could deselect this, and retrieve the master branch. However, this branch has unstable functionality, so building could fail.//



Hit the OK button and be patient, while the repository is being downloaded.

__**STEP 1 : MAKING A VISUAL STUDIO PROJECT FOR BUILDING, BASED ON CMAKE CONFIGURATION**__

//DO NOT FORGET TO STARTUP CMAKE WITH ADMIN SUPPORT/RIGHTS, ELSE THE TOOL CANNOT RETRIEVE ALL NEEDED DETAILS//

Configure your CMAKE, to link to the desired source - and builtfolder. Make sure that the **grouped** and **advanced** options are selected.



Now hit the configure button for the first time. The interface will start configuring your CMAKE, asking you for input when necessary. First off all it will request you to define which **C and C++ compiler** should be used. Select Visual Studio 10 WIN64, but manually select your compilers, NOT automatically. Then go to your Visual Studio installation folder and look for VC/bin/cl.exe. Add this for both C and C++ compiler.

//My tip is to build only what you actually need. If you do not need documentation, then do not select the with option. Attached here is the configuration I used, resulting in a succesful manually build of only the binaries and libraries. It is exactly what is needed, since you can just used the other documentation and files from the downloadable prebuilt packages.//



Hitting the configuration button will generate red valued fields, which are elements where extra information is needed or where information needs to be checked for correctness. Go over each option and fill in all the options that you require. If you are not certain about some option, hit configure again and see if it still remains red. An example configuration file, of all the elements that I selected for building can be downloaded here:



Be prepared to get returned multiple red lines after a new configuration hit. It will keep asking for more parameters if you for example select the TBB optionality. When all red lines are removed, hit the generate button which will creare the solution, that you can build using Visual Studio 2010.

Some options that can reduce the building time, but need to be selected in the CMAKE options:
 * Only the funtionality that is actualy needed. If you do not need python or java bindings, then do not select them.
 * For CUDA support, define using google, what the supported compute compatibility is for your video card. Then built your CUDA only for that GPU architecture support. The compute compability of your architecture can be checked at @https://developer.nvidia.com/cuda-gpus

Let CMAKE generate a solution file, open it in Visual Studio and start building. First for debug, then for release, if both are needed. This can be selected in the top settings.
 * __STEP 2 : BUILD THE PROJECT USING VISUAL STUDIO 2010__**

Some tips while building:
 * If it says it needs to reload files, accept. VS2010 returns and error that the building needs to be stopped. However just click away the error, building still continues fluently.
 * Keep in mind that adding CUDA and TBB support will increase building time a lot.
 * Be patient and it will work out fine.

Finally your destination folder will have a lib and bin folder containing all files needed for programming. You can place them wherever you want, just change the lib and dll path inside your projects.

__**STEP 3 : PREBUILT CUDE LIBRARIES AND BINARIES**__

If someone want to try to use my prebuilt binaries, feel free to download them from this link.

However, they will only work with the following setup
 * Visual Studio 2010
 * Windows 7 Professional x64 bit
 * OpenCV 2.4.5
 * TBB 4.1
 * CUDA 5.0

A lot of extra stuff is left out, since I do not need it, however all basic modules in the C++ interface are included!