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:
- Install the Express Edition of 2010 (I tried this on VS2010 Professional).
- 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.
- 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.
- 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.
- INCLUDE PATHS
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:
Read about it here.
LINKER SETTINGS FOR MAKING STATIC LIB
- 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.
LINKER SETTINGS FOR USING COMPILED 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.