Compiling videoInput in Visual Studio 2010

Update: This is old. OpenCV has a pretty decent working camera interface by now. Use that instead. If you still want the DirectShow libs I re-uploaded them for you. Follow the link, Luke.

First of all thanks to Theodore Watson for making the videoInput library! It is pretty handy for using webcams etc.
Compiling it for windows can be "tricky" though. The included instructions are not completely correct and miss some important issues. I tried to make my instructions for Visual Studio 2010 in the same style, but a bit more elaborate. Cross your fingers as YMMV, as usual. Here goes:

  1. Install the Express Edition of 2010 (I tried this on VS2010 Professional).
  2. In the orginal "\videoInputSrcAndDemos\libs\DShow" directory eg. the "basetsd.h" file is b0rked (it doesn't fit winnt.h). Download the adjusted DirectShow libs. Replace or overwrite the "DShow" folder with this. It should save you the stuff mentioned in the "COMPILER ERRORS" section.
  3. First try compiling without this! The Windows SDK installed with VS2010 (at least Professional) should suffice to compile. If you have the Express Edition you might need to install the Windows SDK (choose the appropriate platform). This is >1GB. Yes, I know. I'm sorry, but this saves you having to download the rancid DirectShow and DirectX SDK from 2005.
  4. Preparing the souce code and project settings. Use the project from the VS2008 directory, copy it somewhere and adjust it. Important stuff:
  • Make sure that the "C/C++"->"Preprocessor"->"Preprocessor Definitions" are:
    "WIN32;_DEBUG;_LIB" for Debug and
    "WIN32;NDEBUG;_LIB" for Release
  • Make sure your remove the lines:
    "#define DEBUG 1"
    "#define _DEBUG 1"
    from the start of videoInput.cpp. They make absolutely no sense and produce linker errors.
  • Make sure "Code Generation"->"Runtime Library" is set to use the SAME version of the VS-DLLs in Debug and Release. So either:
    "Multi-threaded DLL" and "Multi-threaded Debug DLL" or
    "Multi-threaded" and "Multi-threaded Debug"
    Don't mix them unless you know what you want to do.
  • Make sure you build differently named libs. Set "General"->"Target name" to:
    "$(ProjectName)" for Release and
    "$(ProjectName)d" for Debug
    This will give you a "videoInput.lib" and "videoInputd.lib" you can keep in the same folder.

    VC++2010 SETTINGS
      Make sure the standard VC include dirs come first, then the Platform SDK, then the other stuff like the DirectX SDK (if you have this).

    • If you get a compiler error error C2146 for winnt.h:
      The problem may be the include order. Make sure the standard VC include dirs come first, then the Platform SDK, then the other stuff.
      If that doesn't help, try renaming/deleting the file "basetsd.h" from the /libs/DShow/Include folder. It may not be compatible with the winnt.h file you're using...
    • If you get a compiler error C4430 in ctlutil.h:
      The problem here is that this member operator function does not have a return type:
      Change it to:
      COARefTime& operator=(LONG);
      Read about it here.

    • Make sure you have your Additional Dependecies in "ProjectSettings"->"Librarian"->"General" set to:
      "dxguid.lib ole32.lib strmiids.lib uuid.lib"
    • And "Link Library Dependencies": set to "yes".
      When it compiles you will get a LOT of warnings but it should build fine - nice static lib.

    • If you get an error about atlthunk.lib add this to your ProjectSettings->Linker->Command Line:
    • The compilation instructions for VS2008 state you should add:
      '/NODEFAULTLIB:"LIBCMT"' to the Linker Settings.
      This is not necessary if you make sure that you have paid attention to 4.


    Can u send us a sample code ....
    It will help us more.....
    Kim said…
    What for?! There is no sample code as such. You should be able to compile videoInput with VS 2010 using the VS 2008 project and making the changes stated here.
    Unknown said…
    I see no "VS2008" folder in the videoInput download. The only download I could find was clicking the "Zip" button here

    Did you use a different download?
    Unknown said…
    Ok, you have to download from here

    The "Zip" button on their github page doesn't include VS2008 et al for whatever reason.
    daveman said…
    It looks like the link to the above 'adjusted DirectShow lib' is not working. Can you please post that lib somewhere? Many thanks for the help!