Installing & Configuring with Visual Studio

In this tutorial, I am using OpenCV 2.4.5 and Visual Studio 2012. But it is almost same for other versions of OpenCV and Visual Studio.

If you want, you can refer to the older post Installing & Configuring OpenCV2.1 with Visual Studio  2010.

There are 2 ways to install OpenCV into your computer. But for a beginner, the most suitable way is the installation by using the pre-built libraries. So, I am going to discuss how to install OpenCV by using pre-built libraries.

First of all you should have a suitable IDE. I installed Visual Studio Express 2012 which is a free edition. (You will need to register by giving your email address to obtain the free product key).

Then you have to download OpenCV from here. You can choose whatever version, you want. I choose OpenCV 2.4.5.

Then double click the downloaded 'OpenCV-2.4.5.exe' file and it will be extracted to whatever location, you give. I gave C:\ as the extracting location.

Then you will need to set up environment variables correctly to be able to use OpenCV.

Steps to Set up Environmental Variable

  • Right click on 'My Computer' and click 'Properties' in the drop down menu. You will see a window like this.
Find Bitness of a Computer
Find Bitness of a Computer

Here the System type is 32 bit operating system. So the system architecture is x86.
If the system type is 64 bit operating system, the system architecture is x64.

Both Visual Studio 2012 and OpenCV2.4.5  supports vc11. So, in this tutorial, I am going to use vc11 as the compiler type. You can find supporting compiler types of OpenCV, if you go to C:\opencv\build\x86 or C:\opencv\build\x64 according to your system architecture.

Remember your system architecture and expected compiler type because you will need this in the middle part of this post.

  • Now you are ready to set the environment variables. This can be done in the command line or by using GUI. I am going to explain the GUI method.
    • Right click on 'My Computer' and click 'Properties' in the drop down menu. You will see a window like this. 

Advance System Settings

    • Click 'Advance System Settings' in the above window

    • Then click 'Environment Variables'
Environment Variables

    • Then click 'New' button at the bottom of the window
New Environment Variable

    • Type OPENCV_DIR against Variable name:. And type the location C:\opencv\build\ against the Variable value:. 
Creating New Environment Variables

    • Then press OK
Now you have added a new environment variable to the system.

Now you are going to edit a system variable.
    • click 'Path' or 'PATH' inside the list of System variables and then click 'Edit' button at the bottom of the window 
Edit Environment Variable

    • Then add a ; to the end of the line and add the following %OPENCV_DIR%\x86\vc11\bin  after the semicolon. x86 is your system architecture and vc11 is the compiler type. How to find your system architecture and compiler type is explained at the beginning of the post. (Don't delete anything. Just append it at the end of the line.)
Edit Environment Variables

Hooray!! You have completed the installation of OpenCV. Next thing you have to do is configuring Visual Studio.

Configure Visual Studio Express
  • Start Microsoft Visual Studio
  • Go to File>New Project...
  • Do everything as shown in the below image and click OK and then click Finish.
Creating new Visual Studio Project

  • Press 'Ctrl' key and then 'W' while holding the 'Ctrl' key in your keyboard. Release both keys. Then press 'S' in your keyboard. Then you will see the 'Solution Explorer' pane in your right or left side of the Visual Studio window. In my case, it is in the right side.

Solution Explorer

  • Then right click on the project name (you have entered this name in a previous step) and then click 'Properties'
Solution Properties

  • Choose 'All Configurations' as indicated in the 1st box. Click the 3 places as pointed by next 3 boxes in the given order. Then copy and paste $(OPENCV_DIR)\include against the 'Additional Include Directories'
Adding Include Directories

  • Click the first 2 places as pointed by first 2 boxes in the given order.Then copy and paste $(OPENCV_DIR)\x86\vc11\lib against the 'Additional Library Directories' 
Additional Library Directories

  • Click as illustrated below
Additional Dependencies

  • After you click the <Edit...> (4th arrow in the above image), dialog box will appear and you have to copy and paste following library file names. If you are using a different version of OpenCV other than 2.4.5, please check the 'C:\opencv\build\x86\vc11\lib' location for respective file names.

These are some of the file names, you can find in the 'C:\opencv\build\x86\vc11' location.

Adding Additional Dependencies

Now click OK

Congratulations!! You have done with all of the configurations of your IDE. Now you are ready to write your first OpenCV application.

Next Tutorial : Basics of OpenCV API

Previous Tutorial : What is OpenCV?


  1. If the system architecture is 64 bit is it safe to assume that all x86 references are changed to x64. I'm having a build error and cant figure it out.

    1. no way... if i'm not wrong, you need to build opencv using 64-bit in VS. see an intro in

      vor VS 2013 you need in CMAKE choose OpenCVXYZ\source to make, Visual Studio 12 Win64 (for VS 2013 Express 64 bit OS), and later somewhere in the lib-folder-linking (Additional Library Directories): OpenCVXYZ\install\x64\vc12\lib

  2. Thanks!!!Very helpful tutorial.
    Note: for Visual studio 2008, you need to use VC9 instead of VC11 here...

  3. How can i keep all the configurations???

    I want that every time to open Visual Basic the Debug will have the libreries and the heads well, every change that you explain in this tutorial.

    It realy heelp me thanks for all. And your time.

    And sorry about my english i know that is not realy good.

    1. You have to use property sheets. Refer to this blog post for more information

  4. Hi,
    This is a great tutorial. Is there a similar one for installation on linux?

    1. Configurations may differ according to your IDE.

  5. This application has failed to start because opencv_core245d.dll was not found .
    how to fix this?

    1. Did you set the path environment variable correctly?

    2. This is the same error that I got. I've set the environment variable correctly, just as mentioned above. How do I make this work?

    3. Please check the location which is pointed by the 'path' variable and verify that 'opencv_core245d.dll' file is present.

    4. opencv_core246d.dll is very much present in the path variable. Just to make sure, where should the binaries built using cmake be placed? Should these binaries be in the same bin folder as x86/vc11/bin?

    5. You can place your binaries in any place if you have set the path environment variable correctly

    6. It is working. Thanks !! :-)

    7. could u say how it worked...i am having same error

    8. I'm having same error..:( its greatful could u say how u got correct .

    9. Hi,

      Try this:

      First, check the version of opencv you are using, and go to "Linker>>Input>>Additional Dependencies," see if the files are of the right version, i.e., if you are using 2.4.9, all the .lib files should have 249 in the file name.

      Second, you cannot load both files with and without a 'd' in the end of the file name, i.e., you cannot load both opencv_core249.lib and opencv_core249d.lib. You should only load opencv_core249d.lib, and the same holds for all other .lib files.

      Please tell me if that work for you.


  6. i have a doubt, when setuping the environment variable path, whether this location C:\opencv\build\x86 specifies the extracted folder of opencv2.4.5.exe or new folder with a name of opencv? confusing... plz clarify.

    1. It is Extracted folder of opencv2.4.5

    2. I Understood. Thanks for your tutorial.

  7. how to configure opencv with cmake as i am working on windows Xp it does not working its give error like "The procedure entry point GetTickCount64 could not be located in the dynamic link library Kernel"I have searched and done lots of method but it still does not working.Now i am really fed up with this please give me some suggestion.

  8. Error. Tried with both system variable and direct directory.

    1>------ Build started: Project: test, Configuration: Debug Win32 ------
    1>Y:\kod\opencv\build\x64\vc11\lib\OpenCVConfig.cmake : fatal error LNK1107: invalid or corrupt file: cannot read at 0x495A
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    1. Got approximatly the same with QT on Windows using msvc++ (vstudio 2012) and opencv prebuilt 2.4.8 :
      C://opencv//build//x86//vc11//bin/opencv_calib3d248.dll : fatal error LNK1107: fichier non valide ou endommagé : impossible de lire à 0x2C8

  9. opencv_245d.dll is missing from your computer error..i am using visual studio 2012...please help me out i have to submit with in two days

    1. Hi Praveen,
      if you are using last opencv library, you mast name the *.lib with the correct name, in your example opencv_246d.dll .
      Let me know if you fix it.

  10. You won't believe the errors I am getting I have tried everything possible to fix these: PLEASE SUGGEST !
    Error 12 error C2447: '{' : missing function header (old-style formal list?) d:\opencv246\build\include\opencv2\core\operations.hpp 117 1 mySeondOpenCVConsoleProject
    Error 45 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int d:\opencv246\build\include\opencv2\core\operations.hpp 133 1 mySeondOpenCVConsoleProject
    Error 46 error C2086: 'int cv::uchar' : redefinition d:\opencv246\build\include\opencv2\core\operations.hpp 133 1 mySeondOpenCVConsoleProject
    Error 47 error C2143: syntax error : missing ';' before '<' d:\opencv246\build\include\opencv2\core\operations.hpp 133 1 mySeondOpenCVConsoleProject
    Error 80 error C2143: syntax error : missing ';' before '{' d:\opencv246\build\include\opencv2\core\operations.hpp 157 1 mySeondOpenCVConsoleProject
    Error 81 error C2447: '{' : missing function header (old-style formal list?) d:\opencv246\build\include\opencv2\core\operations.hpp 157 1 mySeondOpenCVConsoleProject
    Error 82 error C2146: syntax error : missing ';' before identifier 'saturate_cast' d:\opencv246\build\include\opencv2\core\operations.hpp 159 1 mySeondOpenCVConsoleProject
    Error 89 error C2146: syntax error : missing ';' before identifier 'saturate_cast' d:\opencv246\build\include\opencv2\core\operations.hpp 163 1 mySeondOpenCVConsoleProject
    Error 90 error C2433: 'ushort' : 'inline' not permitted on data declarations d:\opencv246\build\include\opencv2\core\operations.hpp 163 1 mySeondOpenCVConsoleProject
    Error 91 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int d:\opencv246\build\include\opencv2\core\operations.hpp 163 1 mySeondOpenCVConsoleProject
    153 IntelliSense: name followed by '::' must be a class or namespace name d:\opencv246\build\include\opencv2\core\operations.hpp 2487 8 mySeondOpenCVConsoleProject
    154 IntelliSense: expected an operator d:\opencv246\build\include\opencv2\core\operations.hpp 2487 22 mySeondOpenCVConsoleProject
    155 IntelliSense: name followed by '::' must be a class or namespace name d:\opencv246\build\include\opencv2\core\operations.hpp 2488 8 mySeondOpenCVConsoleProject
    211 IntelliSense: name followed by '::' must be a class or namespace name d:\opencv246\build\include\opencv2\core\operations.hpp 3013 8 mySeondOpenCVConsoleProject
    212 IntelliSense: a type qualifier is not allowed on a nonmember function d:\opencv246\build\include\opencv2\core\operations.hpp 3013 35 mySeondOpenCVConsoleProject
    213 IntelliSense: name followed by '::' must be a class or namespace name d:\opencv246\build\include\opencv2\core\operations.hpp 3019 8 mySeondOpenCVConsoleProject
    Error 112 error C2143: syntax error : missing ';' before '<' d:\opencv246\build\include\opencv2\core\operations.hpp 179 1 mySeondOpenCVConsoleProject
    Error 113 error C1003: error count exceeds 100; stopping compilation d:\opencv246\build\include\opencv2\core\operations.hpp 179 1 mySeondOpenCVConsoleProject
    114 IntelliSense: this declaration has no storage class or type specifier d:\opencv246\build\include\opencv2\core\operations.hpp 86 18 mySeondOpenCVConsoleProject
    200 IntelliSense: nonmember operator requires a parameter with class or enum type d:\opencv246\build\include\opencv2\core\operations.hpp 2917 28 mySeondOpenCVConsoleProject
    201 IntelliSense: variable "FileStorage" is not a type name d:\opencv246\build\include\opencv2\core\operations.hpp 2917 41 mySeondOpenCVConsoleProject
    202 IntelliSense: variable "FileStorage" is not a type name d:\opencv246\build\include\opencv2\core\operations.hpp 2920 15 mySeondOpenCVConsoleProject

  11. ill tried to do the same thing in a cuda project in visual studio 2012 and doesnt recognize the libraries of opencv, please help

  12. hi it is enough to copy the include file to this path
    C:\Program Files\Microsoft Visual Studio 11.0\VC\atlmfc\include
    creat a folder there and name it opencv
    so done

  13. how to configure opencv2.4.6 in MS visual studio 2012 for windows 8

    1. its the same with opencv2.4.5, only you have to do is change the name, you add the libraries with 46 instead 45 for example opencv_calib3d245d.lib to opencv_calib3d246d.lib, everything its the same.

  14. Man! You're the best, you just saved my life, I have project due in less than 2 months, and everything I need is here :) Thanks a lot

  15. please help me .................i am getting the following error

    C:\Users\saikrishna\Documents\Visual Studio 2010\Projects\consoleapplication1\Debug\consoleapplication1.exe : fatal error LNK1120: 1 unresolved externals

    1. You haven't correctly set the "Additional Library Dependencies" or "Additional Dependencies" as described in the lesson

  16. Hi, Thank you for your tutorial, it was really easy to follow, I have two doubts, if my PC is x64 I have to move all my programs to x64 in the configuration manager? because with the win32 mode I can't execute them.. Second, I have problems when I try to execute the programs in debug mode, it says "The program can't start because MSVCP110D.dll" is missing from your computer, there is a way to solve this? Thank you very much.

    1. Hi, In Configuration Manager, Change Active solution platform from win32 to x64. With this change, i was able to solve above 2 issues reported by you.

  17. To install OpenCV using the terminal on Ubuntu:
    $ su -
    # apt-get update
    # apt-get install build-essential
    # apt-get install libavformat-dev
    # apt-get install x264 v4l-utils ffmpeg
    # apt-get install libcv2.3 libcvaux2.3 libhighgui2.3 python-opencv opencv-doc libcv-dev libcvaux-dev libhighgui-dev

    OpenCV should be installed in /usr/local/ Installation Directory

    You may also want to compile and view examples
    $ cp -r /usr/share/doc/opencv-doc/examples .
    $ cd examples
    $ cd c
    $ sh


  18. Do I have to perform all these steps every time I create a new project?

    1. Properties of your visual studio project can be retained using property sheets. For more information, please go through

  19. i tried to configure opencv 2.4.5 with visual studio-2010 and followed the above mentioned steps on my window 8-64 bit pc but
    i got an error of fatal error C1083: Cannot open include file: 'opencv2/highgui/highgui.hpp': No such file or directory

    please help me out

  20. This comment has been removed by the author.

  21. I followed the tutorial and installed OpenCV 2.4.5 with visual studio 2008 on windows 8 (64-bit). I tried running a very simple program.
    Then I get the following error.
    "Cannot open include file : 'cv.h' : No such file or directory "

  22. Hi thanks very much for the tutorial. It was very helpful , but I got a problem with my visual studio which is a 2010 version . I cannot find the c\c++ directory when I try to configure my visual studio. Please give me any other of your brilliant ideas

  23. Help plz
    LINK : fatal error LNK1104: cannot open file 'opencv_calib3d248.obj'

    1. If You are usıng opencv 2.4.8 then you have to make all the settıngs accordıngly
      because thıs tutorıal ıs for 2.4.5
      so your fıles wıll be opencv_calib3d245.obj

  24. I followed all the above steps but while debugging my open cv program i am getting the following error.
    "The program cant start because opencv-core248d.dll is missing from your computer. try reinstalling the program to fix this problem."
    What should i do now . please solve my query as soon as possible thanks in advance.

    1. In project properties : Configuration properties --> General --> Use of MFC : Use MFC in a Static Library

  25. Please help:

    Fatal error LNK1104: cannot open file 'opencv_calib3d248.obj'

  26. Hey, first of all thanks for the tutorial!
    Is there anything different with opencv 2.4.8 together with Visual Studio 2013? When debugging my programme the following error occurs (I don't know the exact wording in english, I hope you know what I mean ;) ): "name.exe" (Win32): "C:\Windows\System32\ntdll.dll" loaded. Cannot find or open the PDB file.

    Thanks a lot for your help!

    1. I have got the same error..if u solved could u say how it done.
      Thanx in advance

  27. I am getting opencv_245d.dll error..
    it says the program cannot be run because opencv_245d.dll is not present in your system..try reinstalling the software to fix the problem..
    but i have checked in the bin directory..this dll is present there..
    and i have also set the path to the bin variable..
    what else i have to do to get the program running?

  28. one more thing to add..when i run the .exe from the command line the output is coming..but when i do it from vs 2012 it is showing the above error


    Create your own site, avoid blogs. What all you need is router, UTM firewall device, switch, SERVER. Run it 10 hours a day from home.
    Register to

    Network Security, UTM, Next Generation Firewall, Endpoint Security Appliances. FortiGuard Center; Fortinet Blog; Video Library; Contact Us; Products. Network Security.

    mail me :

  30. Is using vc10 for visual studio 2010 right?

  31. Hi. I cannot find the linker. Help. :(

    1. I had the same problem. right click on the 'main' project icon under solution explorer, NOT THE SUBFOLDER

  32. I am unable to do the first page of Configure VS Express. I'm using VS C++ 2013 The New Project available, but I get no response to "Press Ctrl+W, then press S on the keyboard." Solution Explorer does not appear.

    The "Comment as:" below gives me no choice other than the ones shown. I live in N. Calif, USA. I'll just use anon.

    I just decided to start with a clear window to the IDE, and use "Press Ctrl+W, then press S on the keyboard."
    I got this at the bottom of the window: "it was not a command." I tried that 2-3 times, and got nowhere. However, my last try opened the Solution Explorer.

  33. My last words were truncated somehow. I entered, "Having Explorer available does not allow me the follow the configure steps."

    Suggestion. Note to first time posters to Preview before using Publish. If not, then all text is wiped away from Publish.

  34. I finally was able to push ahead by ignoring the Ctrl+W,S above, and got to the end.

    I missed early this is for 2.4.5, and noticed instructions weren't quite the same and the "look" of the windows as I did the configuration. I did the lib stuff at the end. I'm using 2.4.6.

    I suspect I will discover some problems, since the OPENCV_BUILD or DIR were put into the path differently for the config and install work.

  35. Thanks very much you saved a lot of time for me =)

  36. Got this error LNK1112: module machine type 'x64' conflicts with target machine type 'X86' at my stdafx.obj when my target machine was x64 in the Linker, but when I changed it to x86, the same error popped out again, with module machine type 'x86' conflicts with target machine type 'X64'.

    Does anyone have this problem? I am using 64-bit OS.

    1. Trying to configure mine too now and am having the same problem. Were you able to solve the problem and can you help please or anyone.

  37. vUsing OpenCv2.4.8 through V.S.2012 on windows 8
    and durign run i got this Error

    Error 1 error C1083: Cannot open include file: 'opencv2/core/core.hpp': No such file or directory

    What can i do to solve it !!,thank you .

  38. please help
    LINK : fatal error LNK1104: cannot open file 'opencv_calib3d248.obj'
    please help me with this and its urgent please

  39. Nice blog !!! Its can solve you querry about bootmgr missing error in windows 7 click this link and free from your windows 7 realted problem.
    BOOTMGR Missing in Windows 7
    Aalia lyon

  40. I tried to update my new laptop with Windows and the entire thing got shut down. I had to send it in to another state to get it checked out. I should have just taken it to someone before the problem got to be this big.

  41. help...!!! i have 64-bit OS,using VS2010 with openCV2.4.5...!!! Getting this:" Unable to start program 'C\users\ss\Documents\Visual Studio 2010\projects\helloworld\Debug\helloworld.exe'. The system cannot find the file specified."

  42. i am using visual studio 2012 , why library not include while follow your process correctly ????????
    please help me sir.

  43. ..\opencv\build\x64\vc10
    vc10, vc11, vc12 ???
    my VS 2013 with vc?
    sr my El :( pls help me

  44. I had the same problem, even with the system variables set correctly and using opencv 2.4.9, i kept getting fatal link error opencv_calib3d249.dll cannot be found etcetc. I fixed it finally by just removing the system variables from all the configuration properties, for example:
    under C++/General, for addition include directories my file path is: E:\OpenCV\opencv\build\include
    Same idea for Linker/General I have path set to: E:\OpenCV\opencv\build\x64\vc12\lib
    And then under Linker/Input if you are using a different version of opencv you MUST MUST MUST read the file names in the lib file you are using, they are different for each version of opencv. Here is all the dependencies for Opencv 2.4.9 that I could find.