Installing OpenCV on Windows 7 Professional x64

Many of us, who are currently doing research in the field of image processing or video processing, must have heard of the software library OpenCV. It is a great tool for video and image processing and well suited for practical implementation. However, the installation of OpenCV is not quite straight forward. If you are using a 32-bit operating system, then you are in luck. You will find 32-bit executables ready for deployment. But if you happen to use a 64-bit operating system, you might need to build the OpenCV from scratch. It should be noted that, you can build OpenCV whilst using a 32-bit OS as well. But for 32-bit OS users, there are easier solutions. I will write step-by-step instructions for installing OpenCV 2.1.0 on a 64-bit Windows 7 Professional.

You will need the following softwares:

  1. Microsoft Visual C++ 2010 Express (available for free download here)
  2. Cmake 2.8.2 (available for free download here)
  3. OpenCV 2.1.0 (available for free download here)

I assume that you have already installed Microsoft Visual C++ 2010 Express. If you haven’t, install it first. The installation is pretty straight forward. Also install Cmake 2.8.2. While installing, don’t forget to select the checkbox labeled “Add CMake to the system PATH for current user”. Now, follow the steps below to install OpenCV:

  • Extract the OpenCV 2.1.0 zip file to somewhere convenient location. I will use “C:\OpenCV” path.
  • Start Cmake 2.8.2 GUI
  • Type “C:\OpenCV” under “Where is the source code” text box
  • Type “C:\OpenCV\build” under “Where to build the binaries” text box
  • Click on “Configure”
  • Select “Visual Studio 10” from the drop down list. Click Finish
  • You might have to specify some options after clicking on “Configure”. Select all the check boxes that appear in red color. Click “Configure” until the “Generate” button activates. Click on “Generate”
  • Open Microsoft Visual C++ 2010 Express. From FILE menu, select OPEN and then PROJECT/SOLUTION
  • Navigate to “C:\OpenCV\build” and select “OpenCV.sln” to  open
  • Wait till all the files are found and Microsoft Visual C++ 2010 Express be ready
  • Select BUILD SOLUTION from BUILD menu
  • Close all the softwares running
  • Right click on My Computer and select Properties
  • Click on “Advanced System Settings”
  • Click on “Environment variables”
  • Under “System variables” select “Path” and then click on Edit
  • Add a semicolon (;) to the end of the present text and then add “C:\OpenCV\build\lib\Debug”
  • Click OK thrice
  • Your OpenCV is now built and installed correctly according to your OS
  • You should restart you PC now before trying an OpenCV program
  • After restarting, open Microsoft Visual C++ 2010 Express and select “New Project”
  • Select Win32 console application and give it a name
  • Select PROPERTIES from PROJECT menu
  • Under “Configuration properties” select “VC++ directories”
  • Add “C:\OpenCV\include\opencv” under INCLUDE directories
  • Add “C:\OpenCV\build\lib\Debug” under LIBRARY directories
  • Add “C:\OpenCV\src\cv; C:\OpenCV\src\cvaux; C:\OpenCV\src\cxcore; C:\OpenCV\src\highgui; C:\OpenCV\src\ml;” under SOURCE directories
  • Select LINKER and then select INPUT and add “cv210d.lib;cxcore210d.lib;highgui210d.lib;” under “Additional dependencies”

Now, write a program, select BUILD SOLUTION form BUILD menu. Then select START DEBUGGING from DEBUG menu. Your program should run without any errors 🙂

Advertisements

32 thoughts on “Installing OpenCV on Windows 7 Professional x64

  1. Just a small note, if you want to run your program by pressing F5 then you should add in your path variable the location of the dlls (bin directory)

  2. Nice post. I was checking constantly this blog and I’m quite impressed! Extremely helpful information particularly the first part. I care for such information much. I was seeking this certain info for a very long time. Thank you and good luck.

  3. Thank you for the great step by step installation guide . Unfortunately I still have some problem. I have all the libraries you mentioned added to the Additional Dependency including:
    C:\OpenCV\build\lib\Debug\cv210d.lib
    C:\OpenCV\build\lib\Debug\highgui210d.lib
    C:\OpenCV\build\lib\Debug\cvaux210d.lib
    C:\OpenCV\build\lib\Debug\cxcore210d.lib

    But I still get the following 7 errors:

    Error 1 error LNK2019: unresolved external symbol _cvReleaseImage referenced in function _wmain c:\testCV\OpenCV_Helloword\OpenCV_Helloword\OpenCV_Helloword.obj OpenCV_Helloword
    Error 2 error LNK2019: unresolved external symbol _cvDestroyWindow referenced in function _wmain c:\testCV\OpenCV_Helloword\OpenCV_Helloword\OpenCV_Helloword.obj OpenCV_Helloword
    Error 3 error LNK2019: unresolved external symbol _cvWaitKey referenced in function _wmain c:\testCV\OpenCV_Helloword\OpenCV_Helloword\OpenCV_Helloword.obj OpenCV_Helloword
    Error 4 error LNK2019: unresolved external symbol _cvShowImage referenced in function _wmain c:\testCV\OpenCV_Helloword\OpenCV_Helloword\OpenCV_Helloword.obj OpenCV_Helloword
    Error 5 error LNK2019: unresolved external symbol _cvNamedWindow referenced in function _wmain c:\testCV\OpenCV_Helloword\OpenCV_Helloword\OpenCV_Helloword.obj OpenCV_Helloword
    Error 6 error LNK2019: unresolved external symbol _cvLoadImage referenced in function _wmain c:\testCV\OpenCV_Helloword\OpenCV_Helloword\OpenCV_Helloword.obj OpenCV_Helloword
    Error 7 error LNK1120: 6 unresolved externals c:\testCV\OpenCV_Helloword\Debug\OpenCV_Helloword.exe 1 1 OpenCV_Helloword

    I am using Win7 x64, and MS VS 2010.

  4. I think you meant to add the C:\OpenCV\build\bin\Debug to the Path system variable in System setting. I did that, I restart the PC, and still get the same errors.

    One think that may have caused a problem is that, When I was trying to install the CMake, After I choosed “add CMake to path”, during installation, it gives and error saying “PATH was too long, unable to …” . Could that be the problem? If so, how can I install CMake without that weird problem?

    Thanks

  5. I have no error when i build the solution
    but when i start debugging i have again the error 0xc0150002 with a black window. ( I try the example on the official site of Opencv )
    I work with visual studio 2010 Professional
    Do you have a idea, maybe visual studio is not installed correctly ?

    thanks

  6. When i compile my program, I have a error message, cxcore210d.dll isn’t found.
    You know what it’s mean ??

    thanks

  7. This helps a lot. Thank you
    But i have a question,
    when in Cmake
    there is TBB_LIB_DIR
    and what directory should i give to the item

    \lib\intel64\vc10?
    or
    \tbb30_20100406oss\lib\ia32\vc10

  8. This helps a lot. Thank you
    But i have a question,
    when in Cmake
    there is TBB_LIB_DIR
    and what directory should i give to the item

    \lib\intel64\vc10?
    or
    \tbb30_20100406oss\lib\ia32\vc10

    thanks

  9. I have a question. I am trying to recompile OpenCv into 64-bit version with its source code, but I have no idea where to start. Could you direct me into the right direction?

  10. thanks a lot for your very good step by step tutorial. It didn’t work for me at the beginning as it indicated that .dll are not found when I ran a solution
    But, now It works well : I just had to copy all .dll from “C:\OpenCV\build\bin\Debug” to “C:\OpenCV\build\lib\Debug”.

  11. thanks, but didn’t work. I have this error:
    ‘OCV1.exe’: Loaded ‘C:\Windows\SysWOW64\ntdll.dll’, Cannot find or open the PDB file
    ‘OCV1.exe’: Loaded ‘C:\Windows\SysWOW64\kernel32.dll’, Cannot find or open the PDB file
    ‘OCV1.exe’: Loaded ‘C:\Windows\SysWOW64\KernelBase.dll’, Cannot find or open the PDB file
    ‘OCV1.exe’: Loaded ‘C:\Program Files\AVAST Software\Avast\snxhk.dll’, Cannot find or open the PDB file….
    Windows7 x64, Visual Studio 10
    Help, please.

  12. Thanx for this step by step writing…. I had big problem with cv201d.dll fill, i did not find out here is that…. I figure out why that happend… when you buid the all project (74) in MVS 2010 be carefull to build all the project… 4 time I make mistake to select downone and my cv201d.dll was not compile… thanx again.

  13. mine is showing an error message:

    ‘the application was unable to start correctly (0xc0150002).click ok to close the application.’

    please help

    • error message:

      ‘opencv_helloworld.exe’: Loaded ‘C:\Users\admin\Documents\Visual Studio 2010\Projects\opencv_helloworld\Debug\opencv_helloworld.exe’, Symbols loaded.
      ‘opencv_helloworld.exe’: Loaded ‘C:\Windows\SysWOW64\ntdll.dll’, Cannot find or open the PDB file
      ‘opencv_helloworld.exe’: Loaded ‘C:\Windows\SysWOW64\kernel32.dll’, Cannot find or open the PDB file
      ‘opencv_helloworld.exe’: Loaded ‘C:\Windows\SysWOW64\KernelBase.dll’, Cannot find or open the PDB file
      ‘opencv_helloworld.exe’: Loaded ‘C:\OpenCV2.1\bin\cxcore210d.dll’, Cannot find or open the PDB file
      The program ‘[1356] opencv_helloworld.exe: Native’ has exited with code -1072365566 (0xc0150002).

  14. I’m getting the following errors despite following the steps you have mentioned. Please help

    abc.exe’: Loaded ‘F:\8th sem project\program files\abc\Debug\abc.exe’, Symbols loaded.
    ‘abc.exe’: Loaded ‘C:\Windows\System32\ntdll.dll’, Cannot find or open the PDB file
    ‘abc.exe’: Loaded ‘C:\Windows\System32\kernel32.dll’, Cannot find or open the PDB file
    ‘abc.exe’: Loaded ‘C:\Windows\System32\KernelBase.dll’, Cannot find or open the PDB file
    ‘abc.exe’: Loaded ‘F:\8th sem project\program files\abc\Debug\cv210d.dll’, Cannot find or open the PDB file
    The program ‘[2336] abc.exe: Native’ has exited with code -1072365566 (0xc0150002).

  15. It is a very good guide. Thanks for the tip: “You should restart you PC now..” to solve the Problem with “C:\Windows\System32\ntdll.dll”, “C:\Windows\System32\kernel32.dll” and “C:\Windows\System32\KernelBase.dll” 🙂

  16. When I run the following test code, I get the following error:
    fatal error C1083: Cannot open include file: ‘highgui.h’: No such file or directory

    // testOpenCVfnl.cpp : Defines the entry point for the console application.
    //

    #include “stdafx.h”
    #include
    #include
    #include
    using namespace std;

    int _tmain(int argc, _TCHAR* argv[])
    {
    try{
    IplImage* img = cvLoadImage( “C:/Users/pek1/Desktop/SS/popup.bmp”,1 );
    cvNamedWindow(“Monas”, CV_WINDOW_AUTOSIZE );
    cvShowImage(“Monas”, img );
    cvWaitKey(0);
    cvReleaseImage( &img );
    cvDestroyWindow(“Monas”);
    throw 20;
    }
    catch(int e){cout<<e<<endl;}
    return 0;
    }

  17. hi everyone, nice post hafiz g. but i have one error plz someone help me. the error is.
    1>LINK : fatal error LNK1104: cannot open file ‘cv210d.lib’

    thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s