11 July 2012

Installation guide: OpenCV 2.4 with Visual Studio C++ 2010

After some trouble installing OpenCV 2.4 in Windows and using it with Visual C++ 2010, I decided to write a post about this, so I can hopefully save you some time figuring this one out. It is based on this wiki, but that describes how to build with CMake etc, which is not necessary (anymore?).


Okay, so first you need to download OpenCV 2.4 here. After downloading, you need to extract it. I have extracted it to "D:\OpenCV2.4.2\" and I will use this folder for the rest of this post, you can change it if you like.

Edit your PATH variable (right click on this computer, properties, then select the tab "advanced" and click on "Environment Variables", which is near the bottom).





Add these paths to your Path Variable:
D:\OpenCV2.4.2\opencv\build\x86\vc10\bin
D:\OpenCV2.4.2\opencv\build\common\tbb\ia32\vc10
Replace the beginning with your install path of course. It think that you would need to replace x86 in the first path with x64 and ia32 in the second path with intel64 if you want to build a 64 bit application, although I am not sure about this.

Now we are ready to create a project with OpenCV. In Visual C++ 2010, create a new Win32 console application called OpenCVTest. Now right click the project and select Properties.


On the left, choose C/C++ and edit the Additional Include Directories. Add these directories:
D:\OpenCV2.4.2\opencv\build\include\opencv
D:\OpenCV2.4.2\opencv\build\include

Now choose Linker and add this directory to the Additional Library Directories:
D:\OpenCV2.4.2\opencv\build\x86\vc10\lib
Again I think you need to replace x86 with x64 if you want to build a 64 bit application.

Now open the Linker group (press the + sign before it) and select Input. Add these lines to the Additional Dependencies:
opencv_core242d.lib
opencv_imgproc242d.lib
opencv_highgui242d.lib
opencv_ml242d.lib
opencv_video242d.lib
opencv_features2d242d.lib
opencv_calib3d242d.lib
opencv_objdetect242d.lib
opencv_contrib242d.lib
opencv_legacy242d.lib
opencv_flann242d.lib
Replace 242 with your version if you're not using 2.4.2. Easiest is to paste these lines in notepad, press CTRL+H and set it to find "242" and replace with "251" (would your version be 2.5.1 for example).

And this one cost me a couple of days to figure out: if you do a release build, please remove all the d's in the above filenames (so opencv_core242d.lib becomes opencv_core242.lib), otherwise it won't run properly!

Finally you're ready to use OpenCV. To test it, paste the following code in your OpenCVTest.cpp file:

#include "stdafx.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>


int _tmain(int argc, _TCHAR* argv[])
{
    IplImage *img = cvLoadImage("D:\\funny.jpg");
    cvNamedWindow("OpenCV",1);
    cvShowImage("OpenCV",img);

    cvWaitKey(0);
    cvDestroyWindow("OpenCV ");
    cvReleaseImage(&img);

    return 0;
}
(Please replace D:\\funny.jpg with a valid path to an image! Also make sure that you use double backslashes in stead of one, this because the backslash is an escape character in C++.)
Now press F5 and it should build and run!

Or, if you like to use the 2.x C++ style, you can also use:

#include "stdafx.h"
#include <stdlib.h>
#include <cv.hpp>
#include <cxcore.hpp>
#include <highgui.h>


int _tmain(int argc, _TCHAR* argv[])
{
    cv::Mat img = cv::imread("D:\\funny.jpg");
    cv::imshow("OpenCV",img);

    cv::waitKey();

    return EXIT_SUCCESS;
}

Please let me know if this worked for you!

291 comments:

1 – 200 of 291   Newer›   Newest»
Adam said...

I got the window to pop up and the image box to appear but it won't display my sample image. It only displays a gray space in the box.

#include "stdafx.h"
#include
#include
#include


int _tmain(int argc, char** argv )
{
IplImage *img = cvLoadImage("D:\sample.JPG");
if(img == NULL) { std::cout << "You're Screwed!" << std::endl; }
cvNamedWindow("Example", CV_WINDOW_AUTOSIZE );
cvShowImage("Example",img);

cvWaitKey(0);
cvDestroyWindow("Example");
cvReleaseImage(&img);

return 0;
}

Michael Jepson said...

You do let it run to the cvWaitKey command? If you put a debug break on the ShowImage line, it won't actually draw the image until the cvWaitKey(0); is called. What happens if you replace it with cvWaitKey(); (without the 0)?

Adam said...

Yes the program ran all the way through. I commented out the debug line and changed the 0 and it still shows a grey image.

#include "stdafx.h"
#include
#include
#include


int _tmain(int argc, char** argv )
{
IplImage *img = cvLoadImage("D:\sample.JPG");
//if(img == NULL) { std::cout << "You're Screwed!" << std::endl; }
cvNamedWindow("Example", CV_WINDOW_AUTOSIZE );
cvShowImage("Example",img);

cvWaitKey();
cvDestroyWindow("Example");
cvReleaseImage(&img);

return 0;
}

Michael Jepson said...

Hmm, I'm afraid I really don't know what could cause this. Have you tried loading another image?
You could also try commenting the cvNamedWindow line, as it is not really necessary, cvShowImage should create a Window if it does not yet exist.

Adam said...

I don't know if this has anything to do with it but this error shows up for all of the open CV dll files in the debug window.

'OpenCVTest.exe': Loaded 'D:\OpenCV2.4.2\build\x86\vc10\bin\opencv_core242d.dll', Cannot find or open the PDB file

Michael Jepson said...

No, those are okay. PDB files contain the debug symbols, if they cannot be loaded, your debugger cannot point you to the correct line of code when something goes awry. In other words, when a bug in OpenCV would produce an exception, you wouldn't be able to see what line of OpenCV code caused the exception.

Gerald said...

can u install opencv with cuda support to run opencv on the gpu!?

Gerald

Michael Jepson said...

Hi Gerald,

I'm afraid I have no experience with Cuda, but you can find a guide here:
http://opencv.willowgarage.com/wiki/OpenCV_GPU

After you successfully build OpenCV, you can follow my guide, but make sure that the paths I use point to the paths in your own build. The first couple (that are added to the PATH variable) should point to directories with dll's in them. Additional Include Directories for the C/C++ compiler should point to directories with header files (.h and .hpp files) and the directory for the Linker should point to a directory with the library (.lib) files.

Good luck!

Anonymous said...

Try changing "D:\sample.JPG" to "D:/sample.JPG".

Michael Jepson said...

Ah, now I see the problem, but somehow I have looked over it: The path to the file should be like "D:\\image.jpg" (notice the double backslash). This because the backslash is an escape character, so you have to escape it to actually have it in the string variable.
I have to admit the mistake was in my example code, I have overlooked this while altering the path to the image (because the path I had was longer and useless to others).

Thanks Anonymous for pointing me in the right direction. Using a slash in stead of a backslash would work too.

arek njalen said...

Thanks to the tutorial. it work so easy in my system.
I almost lost with the CMake. lol

once again.
Thanks.
Sorry for my english.

sundowatch said...

Thanks a lot. I have been trying for 4 days to run codes, but I always get errors. But your way works.

sundowatch said...

Hey guys, don't forget to reboot your computer, after you have done those things.

Michael Jepson said...

Thanks for your message! Glad my guide helped.

Michael Jepson said...

Why would you need to reboot? There's no actual change to your system (other than the changed PATH variable) that needs a reboot as far as I'm aware.

Anonymous said...

Hi,

I am working with windows 7, 64-bit. And I should use VS2008. I did this step "Add these paths to your Path Variable:
D:\OpenCV2.4.2\opencv\build\x86\vc10\bin
D:\OpenCV2.4.2\opencv\build\common\tbb\ia32\vc10"

which I was not sure if was correct for win 64 bit.


I did all the steps. I opened an application in win32. and added all the paths to the program. But when I press F5 I get error which says "this project is out of date, would you like to build it?" If I press yes, I get another error which says: There were built errors. Would you like to continue and run the last successful build?

Michael Jepson said...

Have you tried creating a new project with the example code? It seems you have altered an existing project, which won't build. VC++ always asks if you would like to run the last successful build when a build fails.
What does the error window say?

אור שחר said...

dear Michael!
I tried to use your Installation guide for ver- 2.4.0!
and these build errors Occurred:

Error 1 error C1083: Cannot open include file: 'stdafx.h': No such file or directory

Error 2 IntelliSense: cannot open source file "stdafx.h"

Error 3 IntelliSense: identifier "_TCHAR" is undefined

אור שחר said...

I was wandering if you could help me?

thanks,
Or

Michael Jepson said...

Hi,

If you're not using Visual Studio, you probably don't have precompiled headers. Remove the line
#include "stdafx.h" and als rewrite the main method as such:

int main(int argc, char* argv[])

Hopefully this will work for you.

Michael Jepson said...

I hope so ;-)
See my other post for some ideas you can try to get it to work.

Anonymous said...

error: Unable to start program 'C:\Users\Sahand\Documents\Visual Studio 2008\Projects\OpenCVTest\Debug\OpenCVTest.exe'

The system cannot find the file specified

I opened the debug folder but it was empty.

Anonymous said...

Also would you please explain the below part again. As I said before, I am using Windows 64 bit. I do not know what I need exactly do here. I just copied these two links and added them to the system path. ( at the end of the path)

Add these paths to your Path Variable:
D:\OpenCV2.4.2\opencv\build\x86\vc10\bin
D:\OpenCV2.4.2\opencv\build\common\tbb\ia32\vc10
Replace the beginning with your install path of course. It think that you would need to replace x86 in the first path with x64 and ia32 in the second path with intel64 if you want to build a 64 bit application, although I am not sure about this.

Anonymous said...

Also I used x64 path, is it correct?

Now choose Linker and add this directory to the Additional Library Directories:
D:\OpenCV2.4.2\opencv\build\x86\vc10\lib
Again I think you need to replace x86 with x64 if you want to build a 64 bit application.

Michael Jepson said...

Hi,

You only need to use the 64 bit paths if you actually try to build a 64 bit application. Most probably you're building a 32 bit application, so you can just use the x86 paths. (It should say Win32 in your build configuration in VC++).

About the missing .exe: When VC++ can't properly build your project, it asks if you would like to run the last successful build. Because there was no successful build previously to this one, there is no .exe file, hence the message that it cannot find OpenCVTest.exe. This is "normal" behaviour for when a build fails.

Please take a look in your errors window (Somewhere in the View menu), they will give more information about what is wrong.

Please note: DLL files are loaded at runtime, so they cannot be the reason for a build failing. Any problems with DLL files will only surface when a build was successful and your application was actually started.

אור שחר said...

Hi!
Thanks for the fast replay!
I did what you said but now there's a different error:

Error 1 error C2198: 'cvLoadImage' : too few arguments for call

regarding this line:

IplImage *img = cvLoadImage("C:\\Documents and Settings\\Arogeti\\Desktop\\Chocolate.jpg");

any clues?

Thanks,
Or.

Michael Jepson said...

Hi Or,

Try adding ", 1" after the image. What does your intellisense say? Does it need any extra parameters? You could also try the OpenCV 2.x C++ approach (see the last it of example code in the guide itself), maybe that works better?

אור שחר said...

Now there are 7 new errors, after adding one.
Although, it said: ",int iscolor=1)" while I was typing.
I also tried the cpp approach, and got a lot of errors.
Do you think I should remove the openCV 2.4.0, and install the openCV 2.4.2?
Thanks,
Or.

Michael Jepson said...

Hi Or,

Could you post the errors you get?
Also, trying 2.4.2 wouldn't hurt, as it is (or should be) an improved version of 2.4.0. Maybe it's some sort of bug you're struggling with.

Regards,
Michael

אור שחר said...

Hi Michael,

The errors are:


Error 1 error LNK2019: unresolved external symbol _cvReleaseImage referenced in function _main

Error 2 error LNK2019: unresolved external symbol _cvDestroyWindow referenced in function _main

Error 3 error LNK2019: unresolved external symbol _cvWaitKey referenced in function _main

Error 4 error LNK2019: unresolved external symbol _cvShowImage referenced in function _main

Error 5 error LNK2019: unresolved external symbol _cvNamedWindow referenced in function _main

Error 6 error LNK2019: unresolved external symbol _cvLoadImage referenced in function _main

Error 7 error LNK1120: 6 unresolved externals

Thanks,
Or.

Michael Jepson said...

Hi Or,

These errors are produced by the Linker. Please check the settings under the Linker in the project properties. Do you link to the 32 or 64 bit libraries (*.lib files)?
And did you add the additional dependencies correctly? If you are using version 2.4.0, I think these would be opencv_core240d.lib, rather than opencv_core242d.lib (notice that the version number is inside of the name of the file).

Regards,
Michael

אור שחר said...

Hi Michael,

Under the Linker it says:
Platform: Active(win32)

And under Linker/inputs, it says:
Additional Dependencies: kernel32.lib;user32.lib.....

And I followed your advice and downloaded ver 2.4.2 (I made sure to change the dditional dependencies to 242).

Still the same errors...

Thanks,
Or.

Michael Jepson said...

Please check the Additional Library Directories under the General settings of the Linker, it should point to this directory, where all *.lib files are:
D:\OpenCV2.4.2\opencv\build\x86\vc10\lib

Anonymous said...

1>------ Build started: Project: OpenCVTest2, Configuration: Debug Win32 ------
1>Compiling...
1>stdafx.cpp
1>Compiling...
1>OpenCVTest2.cpp
1>c:\opencv\build\include\opencv2\flann\logger.h(66) : warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(237) : see declaration of 'fopen'
1>c:\users\sahand\documents\visual studio 2008\projects\opencvtest2\opencvtest2\opencvtest2.cpp(4) : fatal error C1083: Cannot open include file: 'highgui.hpp': No such file or directory
1>Build log was saved at "file://c:\Users\Sahand\Documents\Visual Studio 2008\Projects\OpenCVTest2\OpenCVTest2\Debug\BuildLog.htm"
1>OpenCVTest2 - 1 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Michael Jepson said...

Hi,

This means your compiler can't find the highgui.hpp file. You need to add the folder where it resides to the include folders of C/C++ in your project, see this part of the guide:
On the left, choose C/C++ and edit the Additional Include Directories. Add these directories:
D:\OpenCV2.4.2\opencv\build\include\opencv
D:\OpenCV2.4.2\opencv\build\include

Anonymous said...

Thanks a lot for your help. Can you understand what is wrong with it by the above comment? I have no idea why I am getting this error?

As I said before, I am using windows 7, 64 bit. And Visual studio 2008. Do you think these can be a problem?

Anonymous said...

Thanks a lot. I just checked the path. And I copied them here:


C:\opencv\build\include\opencv; C:\opencv\build\include

Michael Jepson said...

Hmm, they seem okay. Can you find the file highgui.hpp? Is it in any of those paths?

Anonymous said...

I deleted the space between the paths, and I run the program again. But I am still getting the same error. At first I get "this project is out of date, Would you like to build it?" and when I press yes, I get the above error.

Michael Jepson said...

I'm not sure how this works in VS2008, but in 2010 you can choose to "edit" the variable and add the two paths on two separate lines. Maybe that is the problem?

Anonymous said...

I removed the space between the paths, but nothing happened. When I run the program it says: " this project is out of date. Would you like to build it?" When I press yes, I get the above error!!1

Michael Jepson said...

Can you add the paths in edit mode, adding them both on a separate line? Also, have you been able to find the file highgui.hpp in any of these folders?

Anonymous said...

Yes, I opened the edit mode, they were on a separate lines. No I cannot find highgui.hpp Where should it be?

Anonymous said...

I found it it is in this path: C:\opencv\build\include\opencv2\highgui

Michael Jepson said...

Could you give it a try with highgui.h in stead of highgui.hpp? I don't have access to my code right now, but maybe I made a mistake and the highgui include should point to a .h file rather than a .hpp.

Anonymous said...

I found highgui.h in this Path: C:\opencv\build\include\opencv

What do I need to do?

Michael Jepson said...

In your code, use "#include <highgui.h>" in stead of "#include <highgui.hpp>".

Anonymous said...

I changed it. Now I got this error: "The program can't start because MSVCP100D.dll is missing from your computer. Try reinstalling the program to fix this problem."

Then?

Anonymous said...

'OpenCVTest2.exe': Loaded 'C:\Users\Sahand\Documents\Visual Studio 2008\Projects\OpenCVTest2\Debug\OpenCVTest2.exe', Symbols loaded.
'OpenCVTest2.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll'
'OpenCVTest2.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll'
'OpenCVTest2.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll'
'OpenCVTest2.exe': Loaded 'C:\opencv\build\x86\vc10\bin\opencv_core242d.dll'
The program '[6832] OpenCVTest2.exe: Native' has exited with code -1073741515 (0xc0000135).

Anonymous said...

I searched and I noticed I might need to change:
Right click the Project under the Solution Explorer and select Properties

On the left hand side, expand “Configuration Properties” (if not already expanded)

Expand “C/C++”

Select Code Generation

Change Runtime Library to “Multi-threaded (/MT)”

Click OK

Now recompile it and it should work flawlessly."

But when I do this, I get the below error:


1>------ Build started: Project: OpenCVTest2, Configuration: Debug Win32 ------
1>Linking...
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __malloc_dbg referenced in function "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z)
1>libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __free_dbg referenced in function "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)" (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z)
1>libcpmtd.lib(stdthrow.obj) : error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function "void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (?_Debug_message@std@@YAXPB_W0I@Z)
1>C:\Users\Sahand\Documents\Visual Studio 2008\Projects\OpenCVTest2\Debug\OpenCVTest2.exe : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://c:\Users\Sahand\Documents\Visual Studio 2008\Projects\OpenCVTest2\OpenCVTest2\Debug\BuildLog.htm"
1>OpenCVTest2 - 4 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Michael Jepson said...

Well, this points to a couple of things:

MSVCP100D.DLL is the debug runtime dll from VS2010.
If you replace the Runtime Library with the non-debug version, you are basically running the app in release runtime. In this case, you need the other *.lib files (see my guide itself for this).
BUT ... the important thing to notice, is that MSVCP100D.DLL belongs to VS 2010, not 2008. It's only now that it dawned on me ... you are using the VS2010 folder of OpenCV.

As you've probably noticed, all the paths I used (like D:\OpenCV2.4.2\opencv\build\x86\vc10\lib) have "vc10" in them, which means VS2010. Because you're using VS2008 (which is VC v. 9), you should have used the paths with "vc9" in them.

Michael Jepson said...

So basically what you need to do now:
Go back to debug runtime, not release.
Leave everything as it is, except the paths with "vc10" in them, replace it with "vc9" (please check if these folders exist!).
And try a new debug run.

אור שחר said...

Hi Michael,

First of all, I want to thank you for all your help so far! it's clear that your realy tring.

I'm not at the lab's computer jest yet, so I didnt get a chans to test your last sugestion, but something else occurred to me, could my build errors be the resolt of the vs2010 expres edition?

I thank you yet agein,
Or/

Michael Jepson said...

Hi Or,

I know for a fact that it works with the Express Edition of Visual C++ 2010. From you earlier post, I also noticed that you are using a 32 bit build (win32), so you should use all the x86 paths.
Also, you state that under Linker/inputs it states kernel32.lib;etc., but I don't see the additional includes that you can find in my guide. Did you add these? (like opencv_core242d.lib etc.)

אור שחר said...

Hi Michael,

Of course I did. ander Linker\Aditional dependencies.
when I'l get to the lab,I'l chek agin.

Thanks,
Or.

אור שחר said...

Hi Michael,

The weirdest thing happened, under Linker/General/Additional Dependencies, the opencv includes did exist, but under Linker/Inputs/Additional Dependencies, the opencv includes didn't exist...

witch made me read your first post again- I fond were I went wrong..

It works now!!!

Thanks!!!!!!!
Or.

Michael Jepson said...

Hi Or,

Good to hear you've got it to work! Good luck with your project!

Regards,
Michael

Anonymous said...

OMG Thanksssssssssss it worked!!!!!! it showed the picture!!!!!
Thank you Thank you so much!! :D
*********************************
I changed the system settings >> environment variable to:
C:opencv\build\x86\vc9\bin
C:\opencv\build\common\tbb\ia32\vc9

I went to the paths above and I noticed both of them have vc8 folder too. Do I need to change them to vc8?

Also, I am using win64 bit. Do I need to change the above paths to:

C:opencv\build\x64\vc9\bin
C:\opencv\build\common\tbb\intel64\vc9

*************************************************

I changed the input path to this:
C:\opencv\build\x86\vc9\lib

This path did not contain the vc8 folder.

You are the best!!! Yaaaaaaaay :D

Wisi said...

I need to this "write a code that calls the opencv functions from within matlab"

Do you know how I can do this? Thank you again!!!

psyduck said...

Hi Michael,

thanks for the great tutorial. you rock!

- Psyduck

Michael Jepson said...

Hi Psyduck,

Thanks for your message, good to hear my guide is actually helping people!

Regards,
Michael

Michael Jepson said...

Hi,

Good to hear you finally got it to work, vc9 = Visual studio 2008, cv10 = visual studio 2010. I think vc8 = Visual studio 2005, so don't use those.

Regards,
Michael

@Wisi: I'm sorry, I don't have Matlab now and I haven't tried getting OpenCV to work with it. But Matlab already has a lot of ways to work with images, seen as they are also just matrices. I know I have used Matlab once to write a program for gesture recognition and as far as I can remember I just used "plain" Matlab functions to do so.
Good luck with your project!

Anonymous said...

Thank you Michael.

Mlondono said...

It worked for me. Thanks a lot.

Darshan Sreenivasamurthy said...
This comment has been removed by the author.
Michael Jepson said...

Hi Darshan,

Did you add the Additional Library Directory and Additional Dependencies under "Linker"? These errors indicate that your Linker cannot find the *.lib files.

Regards,
Michael

Darshan Sreenivasamurthy said...

Hello Sir

Please guide

error LNK2019: unresolved external symbol _cvNamedWindow referenced in function _wmain......

Why am i getting this error

Thanks and Regards
Darshan

Darshan Sreenivasamurthy said...

Hello Sir

I am happy that you are replying..

I did add both of the link...But still error.
Kindly help me sir.

C:\OPENCV1\build\x64\vc10\lib


opencv_core240d.lib
opencv_imgproc240d.lib
opencv_highgui240d.lib
opencv_ml240d.lib
opencv_video240d.lib
opencv_features2d240d.lib
opencv_calib3d240d.lib
opencv_objdetect240d.lib
opencv_contrib240d.lib
opencv_legacy240d.lib
opencv_flann240d.lib

Thanks in Bunch
Darshan

Michael Jepson said...

Hi Darshan,

I noticed that you are linking to the 64 bit versions of the libraries. Are you actually building a 64 bit app? You are probably doing a 32 bit build, even though you are working on a 64 bit computer. When you try to do a 32 bit build, the linker needs the 32 bit libraries too.
Please check your build configuration in Visual Studio. Either set it to a 64 bit build and use the 64 bit libraries (and binaries), or have it on 32 bit (Win32) and use the 32 bit paths as used in this guide.

Regards,
Michael

Anonymous said...

Hi! When I try to compile the program I get the following: Unable to start program "D:\Projects\OpenCV_Hello\OpenCVTest\Debug\OpenCVTest.exe" The system cannot find the file specified.

Also I get the following:
1>------ Build started: Project: OpenCVTest, Configuration: Debug Win32 ------
1>LINK : fatal error LNK1104: cannot open file 'opencv_core242d.lib'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

What should I do?

Michael Jepson said...

Hi,

The first error is a result of the second; because it didn't build, there is no .exe to run.

About the second error: for some reason your Linker cannot find the .lib file(s). Please check both the path that you have set for the linker (Additional Library Directories) and the Additional Dependencies (the list of .lib files). One of these contains an error.
It might also be that you are pointing to the wrong version, i.e. the 64 bit version, while you are building a Win32 application (you are actually building a 32 bit debug configuration by the way).

Anonymous said...

Thanks for replying! I forgot to add the directory for the additional library directories,so I already fixed that. But now when I compile, I get the following error:

"The program can't start because libgcc_s_dw2-1.dll is missing from your computer. Try reinstalling the program to fix this problem."

Michael Jepson said...

Not finding libgcc has nothing to do with OpenCV. This is a library that is needed when you used gcc (probably MinGW?) as compiler. You are probably not working with VC++, as that would have used the MSVC compiler.
You are better off asking about this error on a forum related to that compiler or IDE.
What you can do is search for this dll on your computer (it's probably where you installed your MinGW or other gcc compiler) and add the path to it to your system's path variable.

Good luck!

P said...

Thank you so much for all of your help. I would like to call the face detection function in opencv. Do you know how I can do that?

Elisa Agustina said...

Hi Michael! It works! Thank you :)

Elisa Agustina said...

Hi Michael,
I want to ask what is CMake and the tortoise SVN actually for in OpenCV project?
And I also want to ask you, are you ever been doing project for detecting hand gesture and make it to become an order in windows, I want to make it become my university project.
Thanks so much.
Cheers :)

Michael Jepson said...

HI Elisa,
Cmake is for building your own version of OpenCV from Source Code, but it's not needed when using the MSVC compiler (the one in VC++), because the OpenCV provide a build with that compiler in the build folder.
Tortoise SVN is an SVN client, which you use to get out from and insert it into a sourcecode repository. You can Google for SVN.
I have also wrote a program for hand recognition when I was at university, but that was with Matlab and very basic operations (OpenCV wasn't there yet, I think). I remember that we created a near-field IR camera (you can find tutorials how to turn a cheap webcam into an IR camera on the internet). Using that, we could more easily segmentate the hand.
After you have a binary image of the hand (with 1 = hand, 0 = not hand), you can use temporal templates to recognise dynamic gestures and contours and other shape information for static gestures.
Through Matlab, we have been able to use it for controlling a video driving game, but to be honest, I don't remember how we did that. All I remember was that you could wave your hands up and down for going slower and faster, left and right for going left and right and that "the finger" would trigger the horn :-D

Anonymous said...

Hi michael,
could really use your help.I had no luck using the opencv tutorials but yours seem to be a lot easier to follow. The build was successful but right before starting displaying the image it will say "The application was unable to start correctly (0x000007b). Click Ok to close the application." Then it shows: new.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Symbols loaded (source information stripped).
'new.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Symbols loaded (source information stripped).
'new.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Symbols loaded (source information stripped).
The program '[8464] new.exe: Native' has exited with code -1073741701 (0xc000007b).

Help? I'm running win 7 x64 with 32bit studio 2010

thanks!

Michael Jepson said...

Hi, please check if the image was properly loaded through imread. Easiest way to do this is to check img.empty(). It wil return true if the image is empty.
If so, check the path to the image and check if you are linking to the right libraries. You need the 32 bit libraries as you are creating a 32 bit build I think (Visual Studio itself is always 32 bit by the way).
Also, please note that the libraries for a debug configuration end in *d.dll, the ones for a release build do not have this trailing d.

Anonymous said...

double checked libraries, they're correct. im not sure about the first part, involving imread. how exactly do i do this? sorry im a real amateur

Michael Jepson said...

If you copy my example code (C++ version), there already is a call to imread in there. After calling that and before calling imshow, try something like:

if(img.empty())
cout << "Image is empty!";
else
{
cv::imshow("OpenCV", img);
cv::waitKey();
}

If the image is actually empty, you might want to check the path to the image file. Did you add the path to the path variable? Try restarting VC++ and/or your computer, it seems this is sometimes needed for the path change to get through.

Anonymous said...

so now its acting weird. now i get First-chance exception at 0x7605b9bc (KernelBase.dll) in new.exe: Microsoft C++ exception: cv::Exception at memory location 0x0040d5fc..
First-chance exception at 0x7605b9bc (KernelBase.dll) in new.exe: Microsoft C++ exception: cv::Exception at memory location 0x0041eb60..
Unhandled exception at 0x775f15de (ntdll.dll) in new.exe: Microsoft C++ exception: cv::Exception at memory location 0x0041eb60..

I see a grey window pop-up now for a second and i see it on the task bar but each time i click on it, it wont actually come up. This is all after restarting. Any ideas?

Michael Jepson said...

Did you try the img.empty() trick? Is the image empty?
Also, since it throws a cv::Exception, try catching it, like so:
try
{
// do work here (like reading and showing img, etc.
}
catch(cv::Exception &ex)
{
cout << ex.what();
}

This will give you the contents of the exception. Most probably an assert error, stating that nr. of channels must be > 0 (which occurs because of passing an empty image to the show command).

Did you try stepping through your code? You can do so by placing a debug breakpoint on a line. When your debugger breaks there, you can step through your code a line at a time with F10 or resume execution with F5.

Anonymous said...

yup i did! i closed up visual studio and it works now! finally!

thank you so much for your help!

Michael Jepson said...

Good to hear that! Good luck with your project!

Elisa Agustina said...

Hi Michael,
For the image hand, should I do training or can I do something more simple than that? because actually I don't know how to do the image training to the application and it seems to be so hard.
And I want to ask, what is the different between we create our project in Debug and Release. :)
thanks

Michael Jepson said...

Hi Elisa,

Like I said, look up on the internet how to make a cheap IR-camera out of a regulare webcam. Using that, you can find skin and the hands. What I did at university involved training, because you don't know the lighting conditions and other ambient lighting, which all influences the colours.

Debug vs Release basically differs in what it says; a debug build is a build that is made for debugging. This means that the debugger can find the line of code where something went wrong (it it did) and it enables you to use break points and stepping through your code step by step. A release build is a build meant for your release environment. Generally this code is optimised and quicker than the debug build (in terms of speed and memory usage). But, release builds are harder to debug, because some of your code might be shuffeled because of optimisations. Therefor, breaklines usually don't work, you can't step through your code step by step correctly (sometimes it works, but it's not reliable) and quite often your debugger doesn't know what line caused an exception if one occurs.

Roo said...

Thank you so much for this post! Spent 2 whole days trying to get OpenCV to work and finally your tutorial helped.. I was being an idiot and setting the libraries to use the 64bit ones because I have a 64bit machine, but I didn't realise that its for when you are making a 64bit program! Silly me!

Thanks again!

Vikram said...

Hi Michael

Thank you so much for this tutorial! It really helped!

My question is, do we have to keep repeating this procedure for every new project that we create in VS2010 in order to run OpenCV in it? Isn't there any way to be able to run OpenCV in every new project? Or a shortcut to activate running of OpenCV in a new project?

I tried running the same code that I used in the Test project where I configured OpenCV, in a new project. I included the line " #include "stdafx.h" ", after which I wrote my code. It didn't work. Couldn't figure out even header files like cv.h, highgui.h

Michael Jepson said...

Hi Vikram,

Good to hear it worked for you. I think it is possible to add these settings more easily, using property sheets. The problem is that these only work in the paid version of Visual Studio and I only have access to the Express edition.

Regards,
Michael

abbas said...

Hi Michael,

Thank you very much it is a really help full article. I am new in C so I have two questions maybe they are very basic
1- It works when i debug and when i try to release the project it does not work.
2- What is a difference when we try to install the OpenCV through the CMake and by following your article? Is only compilation difference?

regards
Abbas

Michael Jepson said...

Hi Abbas,

1. See this remark: "... if you do a release build, please remove all the d's in the above filenames (so opencv_core242d.lib becomes opencv_core242.lib), otherwise it won't run properly!"
2. The only difference is that my guide uses prebuilt libraries, i.e. libraries that the OpenCV crew has already built for you (most probably using CMake and the MSVC compiler).

Regards,
Michael

Srikanth said...

Thanks Michael

Anonymous said...

Thanks so much for your post, Michael. I spent whole 3 day to get opencv with MSVS, searched on internet, read very much guide, finally i found your post. It helped me. So i spent a hour to read all questions and your answers. It gives me more experience.

Brady Tello said...

After spending two days trying to get OpenCV working using various instructions across the web, this was the procedure I ended up using and it worked. Great write up! One weird thing I had to do was restart Visual Studio before it would catch changes I made to my PATH.

Anonymous said...

Thanks you, very much!!!
Anya? Russia, Voronezh

Anonymous said...

Thank you very much..

אור שחר said...

Hi Michael!

Can you help me agein?
Can you post "how to" install opencv on linux?

Regards
Or.

Rodrigo Mallén said...

THANKS A LOOOOT DUDE!! YOU SAVED MY LIFE!! JEJE... JUST ONE QUESTION... WITH THE PROCEDURE THAT WE'VE DONE HERE, AM I ABLE TO USE THE OPENNI LIBRARIES RIGHT NOW? I MEAN, DO I HAVE TO "TURN THE LIBRARIES (OPENNI) ON" BY MEANS OF CMAKE? OR, DO WE HAVE IT ALREADY CONFIGURED? :) THANKS A LOT AGAIN!

Michael Jepson said...

Hi Or,

I think there are various guides for that on the internet. I don't think you can do that without building the sources yourself (usually this is just these steps: "./configure", "make" and "make install").
It all depends on what development tool you are using. If you plan on using a graphical IDE, I'd suggest Qt Creator, it's a solid IDE and provides access to all Qt functionality, which makes programming a lot easier and you can write cross-platform code more easily.

Good luck!

Michael Jepson said...

Hi Rodrigo,

To enable OpenNI, I'm afraid you'll have to make your own build. It's not that hard and there are guides on the OpenCV sites. Just install CMake, run its GUI and point it to the OpenCV directory. There you can configure it. To enable OpenNI, you need the OpenNI libraries on your system, and you can enable it by setting the option to TRUE in CMake.
After you're done with CMake, you can build OpenCV with Visual Studio and you will have your own build, with OpenNI support.

Regards,
Michael

Faraz Khan said...

Thanks a lot for this wonderful guide. i found this by accident =/

I wonder why all guides insist on using cmake even though its not needed for VC2010.

Now my question is I am learning opencv so I make a new project for every task. Do I have to do all this adding aditional directories and linker settings for every project?

Cant I add these once and make these all available for all new projects I make?

Can you please tell me a workaround for this .

Thanks

Michael Jepson said...

Hi Faraz,

Glad to hear my guide helped you. As for adding the settings for eacht project: All I have been able to find was the use of so-called property sheets. They do not seem to be available in the Express Edition of Visual Studio, so I haven't been able to try them out. If you do have a paid version of VS, you could do a search on these and you'll probably be able to use them for this. If you too use the Express edition, I'm afraid you'll have to keep adding them manually.

Regards,
Michael

Faraz Khan said...

thanks a lot for your detailed response. Appreciate it :)

Anonymous said...

Thanks for your tutorial.
You were write in using double "\" in the path of the image.
"C:\\Users\\William\\Pictures\\helloworld.jpg"

Thanks!

Anonymous said...

Hi. I'd like to thank for this tutorial. Almost everything works except getting video from my notebook's camera. I'm sure that camera works because I use it for wideoconferences in skype. I compiled following program:
****************************************
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

using namespace cv;

int main(int, char**){
VideoCapture cap(0);
if( !cap.isOpened() ) return -1;

Mat frame;
const char *window = "Example 2";
namedWindow(window, CV_WINDOW_AUTOSIZE);

while (cvWaitKey(4) == -1) {
cap >> frame;
imshow(window, frame);
}
return 0;
}
****************************************
Program seems to work properly because there is no errors but instead of video I see green picture. I would appreciate if you could help.

Anonymous said...

After building my project successfully, I want to load the project into TMS320C6748 DSP. But it support only .out file. How can I get that file from my project? Please help me.
Thanx in advance.

Anonymous said...

Hi, i got a problem this is my code, it build successfully, but right before starting displaying the image it will say "The application was unable to start correctly (0x000007b). i dont know what to do
and i am a beginner C++

#include "stdafx.h"

#include
#include
#include

int _tmain(int argc, _TCHAR* argv[])
{
IplImage *img = cvLoadImage("foto.jpg");
cvNamedWindow("Image:",1);
cvShowImage("Image:",img);

cvWaitKey();
cvDestroyWindow("Image:");
cvReleaseImage(&img);

return 0;
}

Michael Jepson said...

Hi,

Sorry, I don't know that device. I think you'll have to find out how to compile code for it (and how to deploy it). You'll most probably (unless it supports an x86 instruction set) have to build your own OpenCV binaries for it too.
First try to compile some simple code for it and get it too run, don't try to do it all at once.

Regards,
Michael

Michael Jepson said...

Hi,

Not all cameras agree with the way highgui accesses them. Maybe your camera is one of these.
Just to check if your OpenCV is in order: did you try the example code, loading an image from disk and displaying it? Did that work as expected?

Regards,
Michael

Michael Jepson said...

Hi,

Did you add the path to the DLL's to your system's PATH variable? Sometimes you need to quit and restart Visual Studio before it sees these changes.
Are you building a 32 or 64 bit application? Are you including the right directories for it? (Don't use the 64 bit paths just because you're on a 64 bit computer, usually you're still building 32 bit applications).

Hope this helps!

Regards,
Michael

Anonymous said...

Hi,

Generally after configuring OpenCV in way you showed here I was able to load images and play films (.avi), but not using code you wrote because I cannot include "stdafx.h". How to fix it? Download it and paste from internet...?
And I'd like to ask about my camera if it is possible to make it work? It works while program is opened (LED is indicating it)
PS. I wanted to write in previous post that I see grey image instead of green but I think it isn't so important:)

Regards,
Kamil

Michael Jepson said...

Hi Kamil,

You can remove the include for stdafx.h if you don't have that file in your solution, it is used (and automatically created) when Visual Studio is configured to use pre-compiled headers.
If you are able to play films and display images, your OpenCV is configured properly. If your camera doesn't produce any image, I'm afraid your camera is not compatible.
You could try cap.read(frame); in stead of cap >> frame, it is what I always use. Little chance it makes any difference, but you might as well give it a try.

If not, you could try searching for your specific type of camera and its use in OpenCV, maybe Google can find some information on whether the camera has been used successfully or not.

Regards,
Michael

Anonymous said...

I changed cap>>frame to cap.read(frame) but unfortunately it nothing changed:(
I'll try to ask google for some solution.
Thanks for your replies.

Regards,
Kamil

Anonymous said...

Hi Michael,

I followed your guide and built the code you specified. All worked well until I got an error saying 'This program cannot start because opencv_core 242d.dll is missing from your computer'. I checked and it is there in my bin file! Would you be able to help me with this problem?

Kind Regards,
Conor

Michael Jepson said...

Hi Conor,
This usually happens for one of these reasons:
1. The path with the DLL is not in your system's PATH variable (see the beginning of my guide).
2. Visual Studio didn't notice you changing your PATH variable. Try restarting Visual Studio or your computer.

Regards,
Michael

Anonymous said...

Hello,

I've followed the steps as above.

I have changed the environment variables to vc9 and also the Linker lib dir.

However I am still getting the "Cannot find or open the PDB file" for all the dlls. I can include highgui.h within the code without error. Visual Studio has no errors or warnings for the code.

Another post suggested that Visual Studio needs to be run "As administrator" however this did not alleviate the issues.

So in summary,

Additional Include Directories.
C:\OpenCV2.4.2\opencv\build\include\opencv;C:\OpenCV2.4.2\opencv\build\include

Additional Library Directories.
c:\OpenCV2.4.2\opencv\build\x86\vc9\lib

Environment Variables - Path
C:\OpenCV2.4.2\opencv\build\x86\vc9\bin;C:\OpenCV2.4.2\opencv\build\common\tbb\ia32\vc9

I am using a 64bit machine, with Visual Studio 2010 in Windows 8.

I also tried the "Change Runtime Library to “Multi-threaded (/MT)" however this created more errors. So I am still using the default setting.

Any help with this issue would be greatly appreciated, as this is very frustrating. Clearly, I have missed something.

Kind regards.

D

Error output is....

'OpenCVTest2.exe': Loaded 'C:\Users\MrDaniel\Documents\Visual Studio 2010\Projects\OpenCVTest2\Debug\OpenCVTest2.exe', Symbols loaded.
'OpenCVTest2.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'OpenCVTest2.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'OpenCVTest2.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'OpenCVTest2.exe': Loaded 'C:\OpenCV2.4.2\opencv\build\x86\vc9\bin\opencv_core242d.dll', Cannot find or open the PDB file
'OpenCVTest2.exe': Loaded 'C:\OpenCV2.4.2\opencv\build\x86\vc9\bin\opencv_highgui242d.dll', Cannot find or open the PDB file
'OpenCVTest2.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'OpenCVTest2.exe': Loaded 'C:\Windows\SysWOW64\msvcr100.dll', Cannot find or open the PDB file
The program '[5624] OpenCVTest2.exe: Native' has exited with code -1072365566 (0xc0150002).

Anonymous said...

Hi,

I tried this and got...

Error 5 error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source? c:\users\mrdaniel\documents\visual studio 2010\projects\opencvtest\opencvtest\opencvtest.cpp 20 1 OpenCVTest

Any tips?

Thanks.

Michael Jepson said...

Hi,

Missing PDB files is just indicating that there is no debug information for these dll's (which is normal). You can ignore these warnings. You might want to look up the error code, or try stepping through your code line per line, to see whre the problem occurs.

Regards,
Michael

Michael Jepson said...

Look in the options of your project, there should be an option that says "use precompiled headers". Switch it off to stop VS looking for them.

Regards,
Michael

Anonymous said...

added path to environment variable fixed my problem Thanks!!

Unknown said...

hi,
plz help me , when i run my program a system error comes saying
"the program can't start because opencv_core242d.dll is missing from
your computer. try reinstalling the program to fix this problem."

what should i do

Michael Jepson said...

Hi,

First check whether you have added the PATH to the DLL to your system's PATH variable. If so, try restarting Visual Studio or your computer, to make sure the changes will have effect.

Regards,
Michael

Unknown said...

hey thanks for replying
but after using the above program given by you, i am getting the following errors

1>------ Build started: Project: test3, Configuration: Debug Win32 ------
1>Build started 10/2/2012 2:17:37 PM.
1>InitializeBuildStatus:
1> Touching "Debug\test3.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1> stdafx.cpp
1> test3.cpp
1>e:\programs\opencv\build\include\opencv2\flann\logger.h(66): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> e:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen'
1>c:\users\logan\documents\visual studio 2010\projects\test3\test3\test3.cpp(19): error C2146: syntax error : missing ')' before identifier 'replace'
1>c:\users\logan\documents\visual studio 2010\projects\test3\test3\test3.cpp(19): error C2146: syntax error : missing ';' before identifier 'replace'
1>c:\users\logan\documents\visual studio 2010\projects\test3\test3\test3.cpp(19): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\logan\documents\visual studio 2010\projects\test3\test3\test3.cpp(19): error C2146: syntax error : missing ';' before identifier 'D'
1>c:\users\logan\documents\visual studio 2010\projects\test3\test3\test3.cpp(19): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\logan\documents\visual studio 2010\projects\test3\test3\test3.cpp(19): error C2470: 'D' : looks like a function definition, but there is no parameter list; skipping apparent body
1>c:\users\logan\documents\visual studio 2010\projects\test3\test3\test3.cpp(19): error C2017: illegal escape sequence
1>c:\users\logan\documents\visual studio 2010\projects\test3\test3\test3.cpp(19): error C2017: illegal escape sequence
1>c:\users\logan\documents\visual studio 2010\projects\test3\test3\test3.cpp(19): error C2059: syntax error : '.'
1>c:\users\logan\documents\visual studio 2010\projects\test3\test3\test3.cpp(20): error C2612: trailing 'identifier' illegal in base/member initializer list
1>c:\users\logan\documents\visual studio 2010\projects\test3\test3\test3.cpp(40): fatal error C1004: unexpected end-of-file found
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:04.75
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


plz help me

Unknown said...

FYI- i am new to opencv in fact i have just started it

Michael Jepson said...

It seems like you have my remark "(Please replace ..." also pasted into your code. The code should end after the closing brace (}), which marks the end of the main method.

Regards,
Michael

Unknown said...

well that was the silliest mistake one can do but its still not working
1>------ Build started: Project: test3, Configuration: Debug Win32 ------
1>Build started 10/2/2012 3:45:22 PM.
1>InitializeBuildStatus:
1> Touching "Debug\test3.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1> test3.cpp
1>e:\programs\opencv\build\include\opencv2\flann\logger.h(66): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> e:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen'
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>test3.obj : error LNK2019: unresolved external symbol _cvReleaseImage referenced in function _wmain
1>test3.obj : error LNK2019: unresolved external symbol _cvDestroyWindow referenced in function _wmain
1>test3.obj : error LNK2019: unresolved external symbol _cvWaitKey referenced in function _wmain
1>test3.obj : error LNK2019: unresolved external symbol _cvShowImage referenced in function _wmain
1>test3.obj : error LNK2019: unresolved external symbol _cvNamedWindow referenced in function _wmain
1>test3.obj : error LNK2019: unresolved external symbol _cvLoadImage referenced in function _wmain
1>C:\Users\LOGAN\documents\visual studio 2010\Projects\test3\Debug\test3.exe : fatal error LNK1120: 6 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:04.00
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Michael Jepson said...

It can't find the correct *.lib files. Check the steps that have to do with the Linker. Make sure you use the *d.lib files for your debug configuration and the *.lib (without the extra d) for your release configuration.

Regards,
Michael

Unknown said...

Hi Michael,

sorry to disturb you again but this bloody thing is giving me a really hard time every other time a new error, this time its a system error saying tbb_debug.dll is missing

'test3.exe': Loaded 'C:\Users\LOGAN\Documents\Visual Studio 2010\Projects\test3\Debug\test3.exe', Symbols loaded.
'test3.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'test3.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'test3.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'test3.exe': Loaded 'E:\Programs\opencv\build\x86\vc10\bin\opencv_core242d.dll', Cannot find or open the PDB file
'test3.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'test3.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
The program '[3648] test3.exe: Native' has exited with code -1073741515 (0xc0000135).


Regards,
Logan

Michael Jepson said...

Hi Logan,

Did you add "D:\OpenCV2.4.2\opencv\build\common\tbb\ia32\vc10" to your system PATH variable? If you did, try restarting Visual Studio or your whole computer, sometimes they need a restart before the PATH variable is updated.

Regards,
Michael

Unknown said...

yes, i did that even rechecked it everything was as per your guide but still its not working.

Michael Jepson said...

Can you find the tbb_debug.dll file? The PDB errors can be ignored, that just means there's no debug information for the dll files, but that's correct.

If you can find the tbb_debug.dll, you might try copying it to the directory where your .exe is placed and running it. If this works, it means the file is okay and that the problem is that it cannot be found in any f the system paths.

Regards,
Michael

Anonymous said...

hi micheal..
i'm facing this problem...
the program can't start because opencv_core242d.dll is missing from your computer. try reinstalling the program to fix the problem.
what should i do?
i'm using win7 64bit and VS2010 32bit

Unknown said...

Hi Michael,

probably this will be the last time i'll be disturbing you as this will be my last try at running this hack of software

this is the eror log i am getting plz help me out with this

1>------ Build started: Project: test3, Configuration: Debug Win32 ------
1>Build started 10/4/2012 9:54:43 AM.
1>InitializeBuildStatus:
1> Touching "Debug\test3.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1> test3.cpp
1>e:\programs\opencv\include\opencv\cv.h(63): fatal error C1083: Cannot open include file: 'opencv2/core/core_c.h': No such file or directory
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.91
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Regards,
Logan

Michael Jepson said...

Check your system's PATH variable. You might need to restart Visual Studio or your computer.

Regards,
Michael

Michael Jepson said...

Hi Logan,

Sorry to hear you're having so much troubles. Cannot open a header (.h or .hpp) file means your include directories are not set correctly. See this step:
On the left, choose C/C++ and edit the Additional Include Directories. Add these directories:
D:\OpenCV2.4.2\opencv\build\include\opencv
D:\OpenCV2.4.2\opencv\build\include
On the left of the project settings window that is.

Good luck!

Regards,
Michael

Sarang Kawade said...

Thanks michael. After losing my mind over useless guides and numerous steps, your guide proved to be a big relief considering the simple steps provided. Really grateful to you michael.

demarlio25 said...

Thank you! I have struggled with other tutorial's but was able to get it to work with yours. I had a few snags in there, I changed the path to have / instead of the \\. I also had to restart VS to get everything to work.

Thanks again!

Stephan said...

i did every thing correctly, over and over , but when ı execute the program , a popup shows up but image is not loaded.when i build the program it says;

1>------ Build started: Project: OpenCv2 Start, Configuration: Debug x64 ------
1> OpenCv2 Start.cpp
1>c:\opencv2.4.2\opencv\build\include\opencv2\flann\logger.h(66): error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\stdio.h(218) : see declaration of 'fopen'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Stephan said...

i handle the problem above. But i am using visual studio 2012. Bu open cv is not have that directry

opencv2.4/opencv/built/x86/vc12

it has vc9 vc10 i tried both of them but MSVCP100D.DLL error is happening.is there opencv version for 2012(which i downladed latest) or should i switch back my version to 2012

WHAT SHOULD I DO?:((:(:(:(

MSVCP100D.DLL!!!

Stephan said...

Finally i handle it . i have opened a image :) i am so happy thanks to you. i handle it in 2012 also.if you have had problems like me i just added to windows path all the possible directirios in opencv2.4.2. They are

C:\OpenCV2.4.2\opencv\build\x86\vc10\bin;
C:\OpenCV2.4.2\opencv\build\x86\vc9\bin;
C:\OpenCV2.4.2\opencv\build\x64\vc10\bin;
C:\OpenCV2.4.2\opencv\build\x64\vc9\bin;
C:\OpenCV2.4.2\opencv\build\common\tbb\ia32\vc10;
C:\OpenCV2.4.2\opencv\build\common\tbb\ia32\vc9;
C:\OpenCV2.4.2\opencv\build\common\tbb\intel64\vc10;
C:\OpenCV2.4.2\opencv\build\common\tbb\intel64\vc9;

i higly recommended that if yu have 64 bit or version problems..

Thanks for your information after 6 hours idid it!

Michael Jepson said...

Hi Stephan,

MSVCP100D.DLL is a Microsoft Visual C++ DLL. It should be available on your computer.

Regards,
Michael

Michael Jepson said...

Hi Stephan,

You can ignore this warning, as it is a source file of OpenCV that uses the "unsafe" fopen function.

Regards,
Michael

Michael Jepson said...

Hi Stephan,

Good to hear you got it working. Sorry though that it cost you six hours. Hopefully the rest of your project will go more smoothly!

Regards,
Michael

Shilpa said...

Hi Michael,

I am trying to install OpenCv 2.4.2 on visual studio 2008 with Cuda. I downloaded the OpenCv from the official website, downloaded Cmake. Configured the OpenCv with Cmake. Changed the path variables. And then when i try to build the solution it fails. Below is the error. Please help.


Error 2 fatal error LNK1104: cannot open file '..\..\lib\Debug\opencv_core242d.lib' opencv_ml

sandy darmawan said...

Hi Michael,

I have same problem like him

1>sandy_project.obj : error LNK2019: unresolved external symbol _cvReleaseImage referenced in function _wmain
1>sandy_project.obj : error LNK2019: unresolved external symbol _cvDestroyWindow referenced in function _wmain
1>sandy_project.obj : error LNK2019: unresolved external symbol _cvWaitKey referenced in function _wmain
1>sandy_project.obj : error LNK2019: unresolved external symbol _cvShowImage referenced in function _wmain
1>sandy_project.obj : error LNK2019: unresolved external symbol _cvNamedWindow referenced in function _wmain
1>sandy_project.obj : error LNK2019: unresolved external symbol _cvLoadImage referenced in function _wmain
1>c:\users\z830\documents\visual studio 2010\Projects\sandy_project\Debug\sandy_project.exe : fatal error LNK1120: 6 unresolved externals

i use OpenCV 2.4.0 Beta2

Regards,
Sandy

Michael Jepson said...

That's the linker complaining it cannot find the .lib files. See the steps concerning the linker in the guide. Please note that you need the files with the "d" suffix for debug builds and the files without that "d" for release builds.

Regards,
Michael

Michael Jepson said...

Hi Sandy,

Please follow the steps concerning the Linker in the guide. These "external" symbols should be found in the *.lib files. Take care to use the correct ones, those ending with a d for your debug build and those without the d for your release build.
By the way, why are you using a beta version of opencv, when you can get version 2.4.2 from the site?

Regards,
Michael

Shilpa said...

I have linked the path containing all the .lib files in the project->properties. Did try restarting the computer. Really confused with this error.
Versions i use: it is a 64 bit Windows 7 OS
OpenCv: 2.4.2
Visual Studio: 2008 and 2010(tried with both)
Cuda: 4.2 and 4.1
Cmake: 2.8.9
Graphics card: NVIDIA Geforce GTX 550 Ti

Does it have something to with this?


Michael Jepson said...

Hi Shilpa,

First of all I have to admit I have never built a Cuda enabled version, but I have build custom versions using CMake. Did you use the CMake GUI to configure it? All I know is you tell CMake to create a folder with all the stuff you need to build a version using Visual Studio and it creates a .sln file that you can just open and build with Visual Studio. Even without doing anything in Visual Studio itself, the .sln should just work.

What I assume is that you have more errors before this fatal one. Since you are building your own version, you are also building your own .lib and .dll files. Not finding the .lib file in the debug folder woud mean that building this lib file failed. Try finding why in the error log.

Regards,
Michael

Maria Zafar said...

Hi, I am using windows 7 with 32-bit OS and i have installed opencv 2.4.2 with vs 2010 and when I the the code above by following instructions with it gives me this error:the program cannot start because opencv_core242.dll is missing from my computer although I have the complete file of opencv if I see the size.Thanks

Harsha S said...

Hi
could you please let me know how to change linker configurations(u asked to include few libraries in linker) in DevC++ new version.
or the procedure perhaps .. .i included the c++ includes, code complies fine . .but lots of linking error

Wajihullah Baig said...

Thanks indeed. Was a charm!

Michael Jepson said...

Hi Maria,

Check your system's path variable. Does it point to the directory with these dll's? You might need to restart your computer or Visual Studio for any changes to this variable to work.

Regards,
Michael

Michael Jepson said...

Hi Harsha,

I have never worked with DevC++ myself, but I'm sure there is some settings for your linker in there too. In Qt Creator it is listed under "LIBS", maybe you can use something like that in DevC++?

Regards,
Michael

xavier regidor said...

Hi Michel,

I 'm using Win64 with VS 2010 and I'm trying to do a project vith openCV 2.4.2. but I always have the same problem (added at the end).

I also tried to do your simply test to open an image, and with opencv 2.2 it hasn't been any problem but with 2.4, version what I need to my project, the project doesn't work. And also when I build the program it erase me the .exe!!!

'test2.exe': Loaded 'D:\UPC\Projecte\work\OpenCV_242\test2\Debug\test2.exe', Binary was not built with debug information.
'test2.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Program Files (x86)\ThreatFire\TFWAH.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\ws2_32.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\nsi.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
'test2.exe': Loaded 'C:\Windows\SysWOW64\nvinit.dll', Cannot find or open the PDB file
The program '[1812] test2.exe: Native' has exited with code 0 (0x0).

Michael Jepson said...

Hi Xavier,

Those PDB file warnings can be ignored. They just inform you that you have no debug information for those (Windows Native) dll files.
Deletion of the .exe is fairly normal too: When building, first all target files are deleted, so they can be built again. If building fails, the original .exe will be gone.

What IS weird though, is that building seems to go fine, but the problems arise during runtime, which should NOT result in the .exe disappearing.

What catches my eye though, is that it states that the .exe has no debug information. Please check your build configuration, it seems you are building a optimised (release) version in your debug config?

Regards,
Michael

xavier regidor said...

Sorry for my ignorance, I think you mean than in my test2 properties I've a configuration "release" but don't. I have a normal Active(debug).

I've checked the paths, includes and libraries and it doesn't matter. The program never shows me the image.

Thank you,
Xavi

xavier regidor said...

Also in 2.2 version I red about copy the dll's in the debug folder. Is in this version the same?

Michael Jepson said...

Hi Xavier,

Even if you choose your configuration that is called "Debug", you can set it to produce no debug information. Even so, it remains strange that your .exe has no debug information.

You can copy the dll's to the debug folder, but if you have set the PATH variable, that wouldn't make any difference.

Are you sure these are the only warnings/errors you get? These indicate that building was successful, as they are only warnings and even state that the process has exited. (And if it can exit, it was built!)

Regards,
Michael

xavier regidor said...

I also use CRT SECURE NO WARNINGS (including opencv2 library) but the Build Output said me there are 6 unsolved externals. And also this time it has deleted the exe

1>------ Build started: Project: test2, Configuration: Debug Win32 ------
1> test2.cpp
1>d:\opencv2.4.2\opencv\include\opencv2\flann\logger.h(66): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> d:\c\vc\include\stdio.h(234) : see declaration of 'fopen'
1>d:\upc\projecte\work\opencv_242\test2\test2\test2.cpp(15): warning C4129: 's' : unrecognized character escape sequence
1>test2.obj : error LNK2019: unresolved external symbol _cvReleaseImage referenced in function _wmain
1>test2.obj : error LNK2019: unresolved external symbol _cvDestroyWindow referenced in function _wmain
1>test2.obj : error LNK2019: unresolved external symbol _cvWaitKey referenced in function _wmain
1>test2.obj : error LNK2019: unresolved external symbol _cvShowImage referenced in function _wmain
1>test2.obj : error LNK2019: unresolved external symbol _cvNamedWindow referenced in function _wmain
1>test2.obj : error LNK2019: unresolved external symbol _cvLoadImage referenced in function _wmain
1>D:\UPC\Projecte\work\OpenCV_242\test2\Debug\test2.exe : fatal error LNK1120: 6 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Michael Jepson said...

Hi Xavier,

These make a lot more sense. Again, deleting the .exe is normal operation, it needs to delete the old build, to make room for the new one. If the new build fails, you end up with no .exe at all.

There are basically 2 problems:
1: There is an 's' in line 15 of your test2.cpp that makes no sense.
2: Your linker cannot find the *.lib files. Make sure you have entered both the path and lib files as explained in the guide. Also make sure that you use the files with the 'd' at the end of the name for your debug configuration.

Regards,
Michael

Michael Jepson said...

And about the 's' in line 15: You probably have a path there, that contains backslashes (\). Replace them with double backslashes.
Since the backslash is an escape character, it has special meaning. '\\' means '\'. '\n' for instance, is a newline character. '\s' cannot be parsed and would produce an error such as the one you're getting.

You can also replace the backslash with a forward slash (/), which is more widely used too, the backslash is only used in Windows.

Regards,
Michael

xavier regidor said...

You have the reason about the double backslash, sorry for that, but the problem remains and I've checked again the 'd' after all the lib:

opencv_core242d.lib
opencv_imgproc242d.lib
opencv_highgui242d.lib
opencv_ml242d.lib
opencv_video242d.lib
opencv_features2d242d.lib
opencv_calib3d242d.lib
opencv_objdetect242d.lib
opencv_contrib242d.lib
opencv_legacy242d.lib
opencv_flann242d.lib

1>------ Build started: Project: test2, Configuration: Debug Win32 ------
1>test2.obj : error LNK2019: unresolved external symbol _cvReleaseImage referenced in function _wmain
1>test2.obj : error LNK2019: unresolved external symbol _cvDestroyWindow referenced in function _wmain
1>test2.obj : error LNK2019: unresolved external symbol _cvWaitKey referenced in function _wmain
1>test2.obj : error LNK2019: unresolved external symbol _cvShowImage referenced in function _wmain
1>test2.obj : error LNK2019: unresolved external symbol _cvNamedWindow referenced in function _wmain
1>test2.obj : error LNK2019: unresolved external symbol _cvLoadImage referenced in function _wmain
1>D:\UPC\Projecte\work\OpenCV_242\test2\Debug\test2.exe : fatal error LNK1120: 6 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Michael Jepson said...

Hi Xavier,

Did you add the path to these lib files too?

See this step:

---------
Now choose Linker and add this directory to the Additional Library Directories:
D:\OpenCV2.4.2\opencv\build\x86\vc10\lib
Again I think you need to replace x86 with x64 if you want to build a 64 bit application.
---------

By the way, you are most probably building 32 bit application, so use the 32 bit paths. You're only building a 64 bit app if you target platform is set to 64 bit.

Regards,
Michael

xavier regidor said...

with the crt secure no warning definition the problem is about write the exe again:

1>------ Build started: Project: test2, Configuration: Debug Win32 ------
1>LINK : fatal error LNK1168: cannot open D:\UPC\Projecte\work\OpenCV_242\test2\Debug\test2.exe for writing
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I'm a little confused...

Michael Jepson said...

Hi Xavier,

This might happen if you're still running the exe file. Sometimes Visual Studio keeps a lock on it. Best way to solve that is to close Visual Studio and delete the file by hand. After that, you can restart Visual Studio.

This has nothing to do with the "crt no warning", since the others were errors, not warnings. Since this is the first step in buiding the .exe, it fails immediately, before the other errors occur if it cannot delete the file.

Regards,
Michael

xavier regidor said...

Shure i've added the paths in Additional Library Directories (linker), in vc++ library directories (allways with x64 and vc10) and the path in the system it's also good.

gaurav said...

Thanks a lot.This saved a lot of time :)

Anonymous said...

Hi
When I remove those d's from the lib files, and press F5 to run the project I got this error "The procedure entry point ??task_group_context@tbb@QAE@XZ could not be located in the dynamic link library tbb.dll".
But when I add d's to those lib file it is OK and works perfect.
I am using VS 2008.
Could you please tell me whats the problem?

Michael Jepson said...

Hi,

Did you also change your build configuration to release? If you use the release libraries (without the d's) for a debug build or vice versa, you'll get weird problems.

In Visual Studio, you can setup different settings for the release and debug build. That way, you can make the debug configuration include the debug static libraries and the release build include the release static libraries.

Regards,
Michael

xavier regidor said...

I had solved the problem last week finally. It was a problem on version express. Now, with VS10 Pro, I only have problems with my code :)

Thank you Michael,
Xavi

Adam said...

Hi, thanks for your guide. Maybe You should send it to guys who made OpenCV documentation :-) . I spend one day with useless and old data information in his opencv_tutorials. ugh....

I've little sugesstion: add information about diffrent ways of configuration for Debug and Release. It will be more perspicuous then your information about deleating "d" letter.

Best regards
Adam

karanjthakkar said...

Hi Michael,

I followed your tutorial as it is and used the 2nd code snippet given by you. I am running Windows 7 64-bit, Visual Studio 2012 and am building the project in Release mode. I have linked the appropriate libraries too (removing the d's from opencv_core242d.lib, etc.). The program Builds fine. However when I try to Run it, I get an error like this:

"The application was unable to start correctly(0xc000007b). Click OK to close the application"

Am I missing something intuitive?

karanjthakkar said...

I have also used the trick mentioned by you in this comment: http://jepsonsblog.blogspot.com/2012/07/installation-guide-opencv-24-with.html?showComment=1344885547363#c6185374653947594381

But that does nothing.

Nour khashan said...

i have problem it say to me
"'opencv.exe': Loaded 'C:\Users\Noor\Documents\Visual Studio 2010\Projects\opencv\Release\opencv.exe', Symbols loaded.
'opencv.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
The program '[4012] opencv.exe: Native' has exited with code -1073741515 (0xc0000135)."



and give me message said
the program can't start because opencv_core242d.dll is missing

how can i solve it ??

Michael Jepson said...

Hi Nour,

Please check your PATH variable. If it is correct, try restarting Visual Studio or your computer. The error here is that the dll files are in these directories and cannot be found.
The warnings about the missing PDB files can be discarded, they just say you have no debug information for the mentioned dll's, but that is normal.

Regards,
Michael

Michael Jepson said...

Hi Karanjthakkar,

Does it give any other information why the application could not start correctly? Is it missing some dll files for instance?
If you just added the paths to your system's PATH variable, you sometimes need to restart your computer, so you might as well give that a try.

Regards,
Michael

Nour khashan said...

I restart my computer and then give me this message

Unhandled exception at 0x77d115de in opencv.exe: 0x00000000: The operation completed successfully.

and message in command

OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in unkown function

Michael Jepson said...

Hi Nour,

You are probably building a release version using the debug libs, or vice versa. If you are building a release version, use the .lib files without a 'd' at the end, if you are building a debug version, use the .lib files that end with a 'd'.

Regards,
Michael

Nour khashan said...

I'm already using release vision and the .lib file doesn't contain 'd' at the end

Michael Jepson said...

Hi Nour,

Are you sure about the .lib files? You said in your first post:
"and give me message said the program can't start because opencv_core242d.dll is missing"

If the program is looking for a *d.dll file, it means you are using a *d.lib file. I suggest you look over your .lib files and make sure you are not using any debug libraries.
If that's not it, I'm a afraid I'm at a loss here. The only reason I have ever seen for producing these "weird" errors is using the wrong version of libraries.
You haven't changed anything else in your build configuration, have you?

Regards,
Michael

Nour khashan said...

"and give me message said the program can't start because opencv_core242d.dll is missing"

this error doesn't appear to me again after restarting the pc

and this is the .dll file that i wrote it

opencv_core242.lib
opencv_imgproc242.lib
opencv_highgui242.lib
opencv_ml242.lib
opencv_video242.lib
opencv_features2d242.lib
opencv_calib3d242.lib
opencv_objdetect242.lib
opencv_contrib242.lib
opencv_legacy242.lib
opencv_flann242.lib

Michael Jepson said...

Hi Nour,

The error does not reappear, because your system can now find the file. But that still leaves me wondering why it would look for a debug dll in a release build. This can only mean that you have changed the runtime in your release build settings, which make it look for debug libraries, even though you have set it to release build. I assume you have been trying some other settings in the configuration when it couldn't find the dll's or something.

I suggest restarting from scratch with a new solution, to make sure this is not the problem.

Regards,
Michael

Alvin Chen said...

Hello,

Thank you for the great tutorial. One question: What is the purpose of adding this path to environment variables? C:\opencv\build\common\tbb\ia32\vc10

When I extract my opencv 2.4.3 package to the C: drive, there is no build/common folder.

Regards,
Alvin

Michael Jepson said...

Hi Alvin,

These contained the tbb libraries in the 2.4.2 version. They allow for multi-threading within the OpenCV libraries. It seems they changed this in version 2.4.3. If it compiles and runs, you're probably ok. Anything built against version 2.4.2 wouldn't run without this path, so I guess if it can run without it now, it won't need it at all.

Regards,
Michael

Žiga Stegu said...

Thanks for this great tutorial. Works as written for my OpenCV 2.4.0, Visual Studio 2010 setup.

laiza Nisar said...

I am trying to run the sample code of face detectt give the error.it gives the fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
but when I include "StdAfx.h" it gives the following error
'OpenCVTest.exe': Loaded 'C:\Users\XYZ\Documents\Visual Studio 2010\Projects\OpenCVTest\Debug\OpenCVTest.exe', Symbols loaded.
'OpenCVTest.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'D:\OpenCV2.4.2\opencv\build\x86\vc10\bin\opencv_core242d.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded.
'OpenCVTest.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
'OpenCVTest.exe': Loaded 'D:\OpenCV2.4.2\opencv\build\common\tbb\ia32\vc10\tbb_debug.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'D:\OpenCV2.4.2\opencv\build\x86\vc10\bin\opencv_imgproc242d.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'D:\OpenCV2.4.2\opencv\build\x86\vc10\bin\opencv_highgui242d.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\user32.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\gdi32.dll', Cannot find or open the PDB file

'OpenCVTest.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7600.16385_none_ebf82fc36c758ad5\comctl32.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\avifil32.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\winmm.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\msacm32.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\msvfw32.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\shell32.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\shlwapi.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\avicap32.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\version.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'D:\OpenCV2.4.2\opencv\build\x86\vc10\bin\opencv_objdetect242d.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\imm32.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\msctf.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\ProgramData\Browser Manager\2.3.787.43\{16cdff19-861d-48e3-a751-d99a27784753}\browsemngr.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\imagehlp.dll', Cannot find or open the PDB file
'OpenCVTest.exe': Loaded 'C:\Windows\System32\psapi.dll', Cannot find or open the PDB file
The program '[56520] OpenCVTest.exe: Native' has exited with code -1 (0xffffffff).

laiza Nisar said...

I am new to opencv it is the first program i am running .kindly help me......

Michael Jepson said...

Hi Laiza,

There is no actual error in your message. All the warnings "Cannot find or open the PDB file" are just warnings and can be ignored. They just tell you there is no debug information for the system dll's, which is normal.

All I can give as advice for this is to check your system's PATH variable and restart Visual Studio or your computer after that. Hopefully that solves it.

Regards,
Michael

laiza Nisar said...

this is in my laptop path variable...

C:\Program Files\Dell\DW WLAN Card;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\MATLAB7\bin\win32;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\OpenCV-2.1.0\build\bin\Debug;D:\OpenCV2.4.2\opencv\build\x86\vc10\bin;D:\OpenCV2.4.2\opencv\build\common\tbb\ia32\vc10;

laiza Nisar said...

the program given on your blog is running nicely.thanks for replying

Michael Jepson said...

I'm afraid there's too little information in the error to determine what's happening. You could try debugging the code and stepping through it line for line, so you can determine what line of code is producing the error. I expect you have an empty Mat object that is passed to a function, this usually results in a program exit.

Regards,
Michael

laiza Nisar said...

thanks a lot for your help the error is removed and the code is running nicely..

Michael Jepson said...

Hi Laiza,

Glad to hear you got it working. Good luck with your project!

Regards,
Michael

mtik said...

Dear Michael,
Thanks for this wonderful and easy to follow guide but unfortunately, I stuck at the result! :(
I'm having the same problem as Adam. Everything went well except the output window which is showing a gray screen instead of the image. I've tried changing the image path, also added sleep function but nothing worked.
Any solution?

Thanks,
TK

Michael Jepson said...

Hi TK,

Please try removing the backslashes (\) and replacing them with forward slashes (/). So for instance if you have your image at "D:\Images\MyImage.jpg", use it like cv::Mat img = cv::imread("D:/Images/MyImages.jpg");
Hopefully this works.
You might want to check whether the image is empty right after reading it, you can check that with the call:
img.empty();
It will return true iff the image is actually empty.

This can also happen if you are using the debug libraries in a release build or vice versa, so please check whether you are using the right ones (those ending with a 'd' are for your debug build, those without the d are for release builds).

Regards,
Michael

Anonymous said...

what is the function of "stdafx.h" library...?

karanjthakkar said...

Hi Michael,

I got it working using your blog as well as referring some other places. Thanks! You can find the tutorial I wrote here: http://karanjthakkar.wordpress.com/2012/11/21/usin-opencv-2-4-2-with-visual-studio-2012-on-windows-7-64-bit/

Best,
Karan

Michael Jepson said...

It is used for pre-compiled headers. It's a trick to speed up compile times on large projects. You probably don't need it most of the time, but VS uses it per default.
If you want to get rid of it, just remove the file and look in your project settigs. There should be a setting somewhere like "use pre-compiled headers". If you switch it off, it won't be looking for the StdAfx.h file anymore.

«Oldest ‹Older   1 – 200 of 291   Newer› Newest»