- Prepared by Siddhant Ahuja
I was trying to install OpenCV 2.3 on my Windows 7 64-bit machine and i kept getting the error: The application was unable to start correctly (0xc000007b)
I tried chasing the problem down using freely available program Dependency Walker and it looked like my executable project was x86 whereas all the dll files it was loading up were x64. So after many tries including re-building OpenCV using CMake, changing dll links to x86, etc., i finally figured out how to solve this problem, which i have presented as a tutorial below.
This tutorial assumes that you have installed Microsoft Visual Studio 2010 Professional. If you are a student you can get it for free at https://www.dreamspark.com/Products/Product.aspx?ProductId=25.
This tutorial contains the following:
- How to download and install the OpenCV library
- How to manually change the system path to include the bin file
- How to create a project
- How to configure Visual Studio to use OpenCV
- A sample program that displays a video from a camera
Downloading and Installing OpenCV
OpenCV is a computer vision library written mainly in C that focuses on real time video processing. It is open source or free to the public.
- Go to http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3/
- Select the OpenCV-2.3.0-win-superpack.exe file and download it.
- Go the folder where you downloaded the executable file in Step 2 and select “Run as Administrator”.
- The executable file is essentially an archive of files with an extractor built in. It will ask you to select the location where you would like it to extract all its contents. Select: C:\Program Files\ as the path and click Extract. It will create a folder called OpenCV2.3 with the path: C:\Program Files\OpenCV2.3
Manually Changing the System Path to Include the Bin File
- To access the system path in Vista go to Control Panel\System and Security\System and on the left hand side select Advanced system settings this should bring up the Systems Properties dialogue. Click on the Advanced tab and then the Environment Variables button.

- This will bring up the Environment Variables dialogue. In the System Variables box select Path and then Edit

- When modifying the path know that it is sensitive to all characters including spaces. To add the new bin, type a semicolon directly after the text that is there without adding in a space. Next add the path to the bin file. The path is the same as where you chose to install OpenCV back in step 4 of Downloading and Installing OpenCV section plus \bin. For example if you chose to install OpenCV in:
C:\Program Files\OpenCV2.3
For 64 bit Windows, add the following to the system path:
;C:\Program Files\OpenCV2.3\build\bin\;C:\Program Files\OpenCV2.3\build\x64\vc10\bin\
Make sure to restart your computer so the changes can take effect.
Creating a Project
- Click File → New →Project
- In the “Installed Templates” box choose Visual C++ → Win32
- On the right choose Win32 Console Application
- Enter a name for the project and click OK
- Click finish in the dialogue box which appears
Configuring Visual Studio
- Click Project → Properties to access the properties dialog

- In the left box click on Configuration Properties and on the top right click on Configuration Manager

- In the Configuration Manager dialog box that opens up, under Active Solution Platform combo box select New.

- In the New Solution Platform dialog box that opens up, under Type or select the new platform, select x64, copy settings from Win32 and make sure that Create new project platforms is selected. Click OK.

- You will notice that the in the Configuration Manager dialog box x64 platform has now been selected. Click Close.

- In the left box choose Configuration Properties → C++ → General

- In the right box, next to Additional Include Directories type the following text:
C:\Program Files\OpenCV2.3\build\include;C:\Program Files\OpenCV2.3\build\include\opencv;%(AdditionalIncludeDirectories)
IMPORTANT note that all these paths assume that you installed in the default location, if you installed in a different location; for example Program Files (x86) instead of Program Files, make sure you change these paths to reflect that.
- Next in the felt box choose Configuration Properties → Linker → Input

- In the right box, next to Additional Dependencies type the following text:
"C:\Program Files\OpenCV2.3\build\x64\vc10\lib\opencv_core230d.lib";"C:\Program Files\OpenCV2.3\build\x64\vc10\lib\opencv_highgui230d.lib";"C:\Program Files\OpenCV2.3\build\x64\vc10\lib\opencv_video230d.lib";"C:\Program Files\OpenCV2.3\build\x64\vc10\lib\opencv_ml230d.lib";"C:\Program Files\OpenCV2.3\build\x64\vc10\lib\opencv_legacy230d.lib";"C:\Program Files\OpenCV2.3\build\x64\vc10\lib\opencv_imgproc230d.lib";%(AdditionalDependencies)
IMPORTANT note that all these paths assume that you installed in the default location, if you installed in a different location; for example Program Files (x86) instead of Program Files, make sure you change these paths to reflect that.
- Click Apply then OK
Sample Program
This program will capture video from a camera and display it. Press escape to stop capturing and displaying frames.
It may be necessary to change the number in this line of code to select the camera source:
CvCapture* capture = cvCaptureFromCAM(1); // capture from video device #1
If you do not know the video device number just try 0, then 1, 2 or else -1. Copy and paste the following code:
#include "stdafx.h"
#include <highgui.h>
int _tmain(int argc, _TCHAR* argv[])
{
int c;
// allocate memory for an image
IplImage *img;
// capture from video device #1
CvCapture* capture = cvCaptureFromCAM(1);
// create a window to display the images
cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
// position the window
cvMoveWindow("mainWin", 5, 5);
while(1)
{
// retrieve the captured frame
img=cvQueryFrame(capture);
// show the image in the window
cvShowImage("mainWin", img );
// wait 10 ms for a key to be pressed
c=cvWaitKey(10);
// escape key terminates program
if(c == 27)
break;
}
return 0;
}


When I run the program a error appears:
1>—— Build started: Project: zzz2, Configuration: Debug x64 ——
1>LINK : fatal error LNK1104: cannot open file ‘kernel32.lib’
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
what can I do to solve this?
Thanks for the tutorial
What version of Visual Studio are you running? The instructions are meant for Visual Studio 2010 on Windows 7 x64 platform only. If you still keep getting that error try the following:
- http://stackoverflow.com/questions/3926866/lnk1104-cannot-open-file-kernel32-lib
- http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2da4c574-d53d-41d0-b579-c2754463c471
- http://blogs.msdn.com/b/saurabh_singh/archive/2009/01/30/getting-fatal-error-lnk1181-cannot-open-input-file-kernel32-lib.aspx
cheers
sid
You just have to restart your computer or set up your Environment Variables.
Thanks for wonderfull tutorial – It helped me a lot.
I’ve tried lots of methods posted on the net and your post was the only information on the net that helped. Thank You so much!
Thanks a lot ! I spent a lot of time to make it work on dev c++ ! I chose as well “Without using precompiled header” in the “precompiled header section”. It avoid me a compilation error.
Tahnks
Thanks for share!!!
Thanks Yaar…
Just because of this post, I am feeling relaxed now.
I was stuck on this OpenCV configuration for around 4-5 hours. Eventually, I came across your post…
tum nhi hote toh na jaane kya hota
Clear and simple.Muchas gracias!
Absolutely clear and wonderful step by step tutorial…. Great !!
Thanks a lot
I have a problem with step 5. I did everything properly but when I added x64, nothing is added and still wind32 only. I have followed the steps carefully. Please guide me what should I do.
Sincerely
Bandar
Hi
Are you sure you are on a 64-bit machine? The option for x64 should already exist. Once you select it, check in the configuration manager if it has been selected or not. Refer to: http://msdn.microsoft.com/en-us/library/9yb4317s(v=vs.80).aspx for more info
cheers
It works! Thanks!!
Hello sir,
In step 4, I want to select x64, as you mentioned, but there is nothing to select. It is just emply list. I typed x64 because no chioce but also nothing created. So, what should I do now?
King regards
Bandar
You are wonderful;
No you must be god sent!!!
oh my god!
you saved me a lot.
Thank you very much.
for another 10 years
i won’t forget your name
My operating system is windows 7 64 bit.
I have installed SDK and visual c++ express 2010.
I did search in Internet about this problem but without good results.
There is no way for me to troubleshoot this. The option for x64 was there by default for me. If other people encounter similar issues, maybe they can point you to a solution. I will keep this in mind if i think of something.
With Express 2010, you have to have the Windows SDK too. Express doesn’t come with a 64 bit compiler, but SDK does.
Wow – this worked a treat, thanks Man!
I tried all the things you tried before but you really are the Guru here!!!!
Manish
Anyway, thank you so much. I will try to solve this problem.
Sincerely
Hi,
I was having the same problem you described, and now I found out what is wrong. You said you were using Visual Studio C++ 2010 Express Edition. I believe the problem is in you version of VS. I was using the Express, but then I uninstalled it and installed the Professional Edition. By doing this, the problem was solved! Now, the x64 option is there when I follow the steps. Also, the example code worked properly. So, I recommend you to install VS 2010 Professional; if that’s not possible, try using the CMake program to load the OpenCV libraries for your project. Hope this may help you.
Best regards!
It works! Thanks!!
Hello,
I encountered the same problem as Bandar’s. There is nothing to select at Step.4. I am running windows 7 64 bit on BootCamp on my Macbook. But I don’t think it is the reason. Now, I am clueless…
Any suggestions?
Hi,
Try doing what I suggested to Bandar. I think it will solve your problem.
Best regards!
It works really well. Thanks a ton!
Hello DW,
You’re awesome. Now, it works. I did what you told me to do and now everything is fine. Again thank you so much. You really did help me.
Sincerely
Bandar
Hello Siddhant & DW,
Thank guys so much. I’ve seen my FACE with a huge smile. Guys, you have really done well. Now, I can read books about this awesome library.
King regrads
Bandar
You can still use VC++ 2010 Express and build 64-bit applications, but you must also install the “Microsoft Windows SDK for Windows 7 and .NET Framework 4″.
See here for more details:
http://msdn.microsoft.com/en-us/library/9yb4317s(v=vs.80).aspx
And here is the link for the SDK (web install):
http://www.microsoft.com/download/en/details.aspx?id=8279
And another link for the SDK ISO (remember to choose the version for 64-bit machines “GRMSDKX_EN_DVD.iso”:
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=8442
Dino
Hi, I went through all the steps you mentioned, but still I am getting errors “UNRESOLVED SYMBOLS”.
First, I tried to run OpenCV2.1, it didn’t work
Then, I tried to install OpenCV2.3.1, it didn’t work
I tried OpenCV2.3, it’s not working
I am doing all this stuff on the same VS2010. Do you think uninstalling and installing the VS2010 again will make any difference, b’coz I can’t do that.
PLEASE HELP
Unresolved symbols typically implies linker errors. Check the following:
1. Please make sure the path for “Additional Dependencies” is correct. Refer to step 9 under configuring visual studio.
2. The system path should be set properly. Please refer to step 3 under “Manually Changing the System Path to Include the Bin File”. Make sure to restart your computer.
If you still experience a problem, can you please send me the error details?
regards
I made everything step by step. Bu in the end I get a grey skin (instead of a video). I am using windows 7 x86 (but I changed every x64 in the directories with x86. Still nothing….
Hmm, gray window is just a OpenCV HighGUI Window with no content present. Can you check if an image was successfully captured from the webcam? Does the webcam light turn on while capture? Can you pause the code and look at the image structure to confirm data is there?
I don’t have n x86 machine with me to test this out. Maybe someone else here might be able to provide some assistance?
cheers
sid
Can u make a tutorial for Win 7 x86?
The main thing for x86 is to ignore steps 2-5 under Configuring Visual Studio.
Also in step 9 replace x64 with x86 for *.dll file locations.
Rest all should be same. I don’t have a x86 machine to test presently..I have a strong feeling it should work without a problem though.
cheers
sid
is the program work for USB i.e webcam?
Does it work? yes it does
thank you very very much i did it … i saw me wonderful face … hahahaha
it works! Thanks much. It is a great tutorial. I am looking for one more tweaks. Is there any way to permanently add the include directory and linker directories to project settings? I mean, can we add this to a global project settings or something? Otherwise, it is a pain to follow the same configuration steps every time we create a new project.
Hello
Thank You, Thank You, Thank You, Thank You,
A few weeks really had a problem with this tutorial, you saved me
I am the Persian language. Google Translator to translate all your web page and this message has
Thanks, Google Translator
Thank’s Sid.
thank you boss , at last it worked after exploring so many tutorials …
What if i only have Microsoft Visual Studio 2010 Express? Is that OK?
Hey..you could still use the express edition, but some people have had issues with it. A solution was posted by one of the members in the comments section for your product version. Look at: http://siddhantahuja.wordpress.com/2011/07/18/getting-started-with-opencv-2-3-in-microsoft-visual-studio-2010-in-windows-7-64-bit/#comment-411
cheers
It is showing error like
1>proj1.cpp(3): fatal error C1083: Cannot open include file: ‘highgui.h’: No such file or directory
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Moreover when I was creating active platform solution in configuration manager, the “create new platforms” checkbox was not accessible. Please respond..!!!
Hi
If you follow line by line, word by word every step, you should not get an error. However, i can try and troubleshoot the problem that you are experiencing:
1. Please make sure that all the include directories in step 6 and 7 of “Configuring Visual Studio” section, resolve to “actual” directories. You may have OpenCV installed in “Program Files (x86)” folder or directly in “C:\OpenCV\”.
2. If you still get this error, please make sure you have followed “Manually Changing the System Path to Include the Bin File” section. Again, you may have OpenCV installed in “Program Files (x86)” folder or directly in “C:\OpenCV\”.
3. Make sure you installed the right version of OpenCV
5. Make sure you are using it in Visual Studio 2010 Professional addition for 64 bit operating systems.
If you are still experiencing a problem, please put your project into an archive and send it to me, so that i can examine it.
regards
sid
[...] The step by step process is listed in the following link: http://siddhantahuja.wordpress.com/2011/07/18/getting-started-with-opencv-2-3-in-microsoft-visual-st… [...]
IT works…simply best job!!!
Thank you soo much!
I
thanks lot.
Really cool. Thanks a lot !!!
Awesome job Sid.. Its very simple. Great work !
Thank you! After spending days trying to install and get openCV to show video on my PC but to no avail, I finally came across your article. I am on easy street now.
Hey there
Just wanted to thank you for this tutorial; I was stuck on trying to work OpenCV into Eclipse. And your tutorial does work on Visual 2010 Express, however the Create new project platforms box is greyed out so I just ignored the x64 step.
thanks again
Thanks a lot!
Simply perfect! Thanks a lot!
Thanks , I have been searching for it on internet but every where else tutorials are for the previous release but not for the latest one. It helped me a lot.
[...] Getting Started with OpenCV 2.3 in Microsoft Visual Studio 2010 in Windows 7 64-bit [...]
Thank you so much! Believe me, when the program worked I was ready to fall at your feet and hail you. Then I read the comments, there seem to be a hundred like me
Thanks so much. I think the Professional Version of Visual 2010 C++
helped alot along with the instructions. I thought I would never get the 64 bit to work….Thanks a million
Thanks mate, works great.
If you are using Express edition then apart from blog steps and suggestion mentioned at http://siddhantahuja.wordpress.com/2011/07/18/getting-started-with-opencv-2-3-in-microsoft-visual-studio-2010-in-windows-7-64-bit/#comment-411, you have to also set Platform Toolset to “Windows7.1SDK” in Configuration Properties–>General otherwise you will get 2019 error.
1>LINK : fatal error LNK1104: cannot open file ‘C:\Program Files\OpenCV2.3\build\x64\vc10\lib\opencv_core230d.lib;C:\Program.obj’
notice:i cant change my project platform as ‘x64′ even button “Create new project platform” doesnt get selected (in configuration manager)
what to do sir?
Are you using Visual Studio 2010 Professional? These instructions are meant specifically for that version. If you look in the comments, someone has previously suggested how to set it up for express edition.
cheers
I have set up OpenCV over six times and never has it been this easy! Thanks for writing this! You saved me a ridiculous amount of time.
using: Windows 7 x64, Microsoft Visual Studio Ultimate
Mil gracias por este post!!! estuve toda la tarde intentando usar opencv en visual studio y nada funcionaba!!!
Muchas gracias por este aporte. 10 puntos!
solo hay que seguirlo PASO a PASO
Thanks for a great tutorial!!!
Thnx a lot for tutorial!
Thanks for the tutorial! It is my final year project also..
I have a problem to run the code above, it said IntelliSense Identifier “CvCapture” undefined. All the function of “cv….”undefined. What happen?
Thanks a lot too. Really easy opencv setup with your tutorial.
cheers
Torsten
nice! works perfectly
#include "stdafx.h" //error Expected a file name
You get this error if you do NOT create a project with precompiled headers. Please refer to the tutorial for the same.
cheers
sid
thanks for your tutorial.
i run correctly this sample code to receive webcam.
but when i this function to detect face from webcam:
“int detect_faces(IplImage* img)
{
IplImage* gray;
/* Load the face detector and create memory storage
`cascade` and `storage` are global variables */
if (!cascade) {
char* file = “C:/OpenCV2.1/data/haarcascades/haarcascade_frontalface_alt.xml”;
cascade = (CvHaarClassifierCascade*) cvLoad(file, 0, 0, 0);
storage = cvCreateMemStorage(0);
}
/* Convert multichannel to 1-channel for faster processing */
if (img->nChannels == 1) {
gray = cvClone(img);
} else {
gray = cvCreateImage(cvGetSize(img), img->depth, 1);
cvCvtColor(img, gray, CV_RGB2GRAY);
}
/* detect faces */
CvSeq* faces = cvHaarDetectObjects(
gray,
cascade,
storage,
1.1,
3,
CV_HAAR_DO_CANNY_PRUNING,
cvSize(20, 20)
);
int i;
/* Draw red boxes on the faces found */
for( i = 0; i total : 0); i++ ) {
CvRect* r = (CvRect*)cvGetSeqElem(faces, i);
cvRectangle(
img,
cvPoint(r->x, r->y),
cvPoint(r->x + r->width, r->y + r->height),
CV_RGB(255, 0, 0),
1, 8, 0
);
}
return faces->total;
}”
i got error:”this application unable to run correctly (0xc000007b)…”
i think this problem when opens “haarcascade_frontalface_alt.xml”.
how do i correct this error.
pls help me,this’s urgent.
best regards.
Hey
Can’t help troubleshoot someone else’s code. Have you tried contacting the person who wrote this code? Forums are a good place for this as well.
Good luck!
This was very helpful…thanks
Thank you very, very much!
Muchas gracias.
Thanks a lot. You saved my time. Tried this for a few days, but couldn’t find out where I’m going wrong.
Thank you. Very helpful.
Worked on my notebook with webcam, but not on workstation with FireWire 1394b camera …
nice! Thank you.