Notice: MediaWiki has been updated. Report any rough edges to marcan@marcan.st

Getting Started Windows

From OpenKinect
Revision as of 10:22, 6 January 2011 by BankP (talk | contribs) (Glut dependency: in cmake, supply header path up to /include, not /include/GL)
Jump to: navigation, search

Building libfreenect from Source

Getting the source files

There are 2 ways to get the latest source:

  • Go to the OpenKinect project github, select the branch you want (master or unstable for instance) and click the "Download" button (then extract the files to a convenient location).

or

  • Use Git to create and keep an up to date project folder and access any branch locally:

Using Git

  • Download and install Git with these settings:
    • Accept the license etc.
    • Choose the level of shell integration you want
    • Choose "Run git from the Windows Command prompt"
    • Choose "Check out WIndows style, commits Unix-style line endings"
  • Open a Command Prompt, cd to the directory where you want the source folder (libfreenect) created and type:
$ git clone https://github.com/OpenKinect/libfreenect.git
  • Then cd to the libfreenect folder. This is the up to date master branch of the project and you can configure it and build it at this point. You could also create a local branch for the remote unstable branch (or any other existing branch) so that you can conveniently check it out later:
$ git branch --track unstable origin/unstable   
  • The "git branch" command will show you the different branches (here master and unstable) and which one is currently selected. You can also view the development logs for the branch you're checking out with the "git log" command (use shift-Q to exit the log).
  • From now on, you can just cd to the libfreenect folder, and select the branch you want to checkout:
$ git checkout master

or

$ git checkout unstable
  • Also make sure the files are the latest:
$ git pull
  • The contents of the libfreenect folder will interactively change as you checkout a specific branch (magic!) so you don't need to search for a specific "branch" folder inside the libfreenect directory. Just checkout the branch you want to configure and proceed using the libfreenect folder as source.

After you have the source files, you should download the dependencies required to configure and build the library and then install the hardware driver...

Dependencies

For each required dependency, first download and install the libraries (.dll) on your system and then identify the paths to the libraries (.lib or .a) and header (.h) files which you will need later on to configure the source project using cmake:

Dependency Install Library/includes to be used with cmake
libusb-win32 - download and extract the latest libusb-win32-bin-x.x.x.x.zip Find the /bin folder and use the inf-wizard program which will prepare then install the required files to /windows/system32 The /lib and /include folders contain the libraries and header files required to configure the project; depending on the compiler you choose, you may have to specify a different library file:
  • For instance, to configure for MS Visual Studio 2010, use /lib/msvc/libusb.lib or if you plan to use mingw, use /lib/gcc/libusb.a

For more info see the libusb-win32 readme and their wiki

pthreads-win32 - download and extract the latest pthreads-w32-x-x-x-release.exe Find the /lib folder and copy the appropriate library to /windows/system The /lib and /include contain the libraries and header files required to configure the project; depending on the compiler you choose, you may have to specify a different library file:
  • For instance, to configure for MS Visual Studio 2010, use /lib/pthreadVC2.lib or if you plan to use mingw, use /lib/pthreadGC2.a.
  • In both cases you will need to install the corresponding library .dll file to /windows/system i.e. phtreadVC2.dll or pthreadGC2.dll

For more info see the pthreads-win32 readme and their FAQ

Glut - download and extract the latest glut-x.x.x-bin.zip Find the glut32.dll file and copy it to /windows/system With MSVC, the glut.h header file should always be in the /include/GL folder and the glut32.lib library in the /lib folder of your VC tree(for instance /Program Files/Microsoft Visual Studio 10.0/VC/). If you built glut from source, the files should already be there. In cmake-gui, supply the path of the header up to the /include folder (NOT /include/GL) and the path to the library file as required (select the file itself - glut32.lib).

For more info see the glut readme

Driver installation

There are two parts to libfreenect -- the low-level libusb-based device driver and libfreenect itself, the library that talks to the driver. You only need to install the driver once.

General instructions

Plug in your Kinect. The Xbox NUI Motor loads first. Cancel any dialog that searches for drivers and open the Windows Device Manager. Find the Motor device, right click it, and select "update device drivers" and manually browse to /platform/windows/inf inside your libfreenect source folder. After the Motor is installed, the Xbox NUI Camera and Xbox NUI Audio will connect and you can repeat the same thing for those drivers.

Windows 7: step-by-step walkthrough

  • Plug in your Kinect. Windows will warn that no device driver was found for the plugged device (the LED of Kinect will not turn on). If Windows presents a dialog asking to search for drivers, simply cancel it.
  • Open the Device Manager: Start >> Control Panel >> System and Security >> System >> Device Manager
  • A device called "Xbox NUI Motor" should be somewhere there (most probably be under "Other devices") with a small yellow warning symbol "!" on top of its icon. Right click on it, and select "Update Driver Software...", then click on "Browse my computer for driver software".
  • "Browse" and select the folder where the "XBox_NUI_Motor.inf" is located (/platform/windows/inf inside your libfreenect source folder). Click "Next" and if warned by Windows that a non-certified driver is about to be installed, just order it to install it anyway.
  • After that, the Kinect LED should start blinking green. Now there will be two additional devices in the Device Manager list: "Xbox NUI Camera" and "Xbox NUI Audio". Repeat the above instructions for them as well.

You are now ready to build libfreenect and start developing your own software in Windows with Kinect!

Configuring with cmake-gui

Follow these steps to configure libfreenect for compiling:

  1. Download Cmake (Cross-Platform Make) and make sure you have a working C compiler (like Visual Studio 2010 or MinGW)
  2. Launch Cmake-gui and select your libfreenect source folder (where you see /src, /examples etc.) as source, specify an output folder for the makefiles then click on the "Configure" button. (NOTE:: if you plan on changing libfreenect, writing wrappers, or trying the latest developments you might want to download the unstable branch instead. Unstable has the latest commits that have not been fully tested yet.)
  3. Select your C compiler and continue. Several mistakes will be presented as red in the CMake GUI. You must correct these problems. For the libfreenect header you must point at c/include, for USB header c/dependencies/include and so on...(NOTE: For now only select the EXAMPLES and C_SYNC build options. The other build options such as FAKENECT have not been updated for Visual Studio yet. )
  4. Continue the configure process and when errors show up supply the proper paths to the dependencies you have previously downloaded, as discussed. The *_LIBRARY variables need to point to actual .lib files not a folder. INCLUDE variables need to point to the appropriate include directories. You might need to check the "grouped" and "advanced" checkboxes to facilitate the display and to access some variables.
  5. When all errors have been resolved, click on the "Generate" button to create the makefiles for your compiler.
  • Take a look at this sample cmake configuration for MS Visual Studio 2010 for reference: 1 2 3

Compiling

Now that the project is configured, open libfreenect.sln from your output folder and build it with Visual Studio.