C# – On installing OpenCV with VS2010 C# (getting through “cmake error:Error in configuration files. Project Files may be invalid” ?)

ccmakeopencvvisual studio 2010

I have looked around for quite some time trying to get openCV installed. I'm using windows 7, VS2010 C# Express and cmake 2.8.8. For all the tutorials found online, one would simply need to specify the source code path (understood to be the path where opencv folder was extracted) and then the binaries path (understood to be where the openCV source code is to be built, possibly a new directory). The problem is that after populating the source code and binaries' paths, and hitting "configure" the error

"cmake error:Error in configuration files. Project Files may be invalid"

occurs.For a further detailed error log, below was displayed:

CMake Error: Cannot open file for write: C:/Program Files (x86)/opencv/build/CMakeCache.txt.tmp
CMake Error: CMake was unable to find a build program corresponding to "Visual Studio 10". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: Could not find cmake module file:C:/Program Files (x86)/opencv/build/CMakeFiles/CMakeCXXCompiler.cmake
CMake Error: Could not find cmake module file:C:/Program Files (x86)/opencv/build/CMakeFiles/CMakeCCompiler.cmake
Configuring incomplete, errors occurred!
CMake Error: Cannot open file for write: C:/Program Files (x86)/opencv/build/CMakeCache.txt.tmp
CMake Error: : System Error: Permission denied
CMake Error: Unable to open cache file for save. C:/Program Files (x86)/opencv/build/CMakeCache.txt
CMake Error: : System Error: Permission denied
CMake Error: : System Error: No such file or directory
CMake Error: Unable to open cache file for save. C:/Program Files (x86)/opencv/build/CMakeCache.txt
CMake Error: : System Error: No such file or directory


My guess from what I digested online was that there may be incompatibility with cmake and opencv (cmake's installed as x86; opencv as x64bit) and thus I re-downloaded openCV for the 32bit version (I'm running on a 64bit pc though) but still no progress (it would still not configure resulting in the error).
Here is the one I've installed (the win32 suffixed-one) for reference purposes http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.1/ .

It might also be worth the mention that there appeared a multitude of "cannot open file …" messages while extracting openCV (for eg. "Cannot open output file directory goes here\opencv_objdetect240.dll"). This seemed to be for about all the files(the error was repeated as far as I remember almost in every line while extracting, for a different file per line).

This is my first encounter with cmake, and thus am not really acquainted with the steps. I found some instructions directed towards the "CMakeLists.txt" (which was already included in the extracted folder) but do not fully comprehend them. One rather detailed reference was http://thebitbangtheory.wordpress.com/2011/10/24/how-to-use-cmake-with-opencv/ . However I felt steps were not detailed enough (namely steps 3-6). Of the ambiguities, for a cmake novice as myself, was what the "project" refers to, isn't this done once to be able to compile all C# projects that include opencv?

In all cases given the above background, the question is: how can one install openCV to VS2010 C#, overcoming the cmake configuration error (or how could such error be fixed)?


Notes:

  • I have not reliably documented the exact wording of the preliminary
    error (before re-extracting the 32-bit version), but it was as far as
    I recall as that occurring at the moment, the one quoted above.
  • I realise there was a similarly-titled question ( cmake error:Error in configuration files. Project Files may be invalid );
    however the answer did not seem to meet the given situation; then
    again, I could be wrong.

Thank you very much for your time.

Best Answer

OpenCV is a C++ project. And it is not possible to compile it with VS2010 C#.

If want to develop with C# then take a look into EmguCV project which wraps OpenCV for C#/.Net.