Switching to OpenCV 2.0 with VS2005
I’m using OpenCV for some tests, and for some reasons (freelance gigs and Symbian SDK) using MS Visual Studio. As new and shiny OpenCV 2.0 is out I decided to switch to it. As it happen, one absolutely have to read buried in the download section readme, before doing anything.
The thing is, OpenCV 2.0 doesn’t include lib files for VS. They have to be built by user.
So here is step by step retelling of readme:
1. Rename your old OpenCV installation to save it, just in case
2. Download and install OpenCV 2.0a
3. Download and install CMake
4. Reboot (or CMake wouldn’t work)
5. Go to C:\Program Files\CMake 2.6\bin and run cmake-gui.exe
6. In the “Where is the source code” field choose your new OpenCV directory (C:\OpenCV)
In “Where to build the binaries” choose directory for VS compiled OpneCV (C:\OpenCV\VS2005)
7. press Configure button and choose VS2005 (or whatever) as building enviroment
8. Press Generate and VS project will be generated in the C:\OpenCV\VS2005
9. Launch solution and build it. For debug build some projects require debug python libraries. As riseriyo pointed in comments if you have Python installed other than 2.6 that can cause problem.
10. Copy *.lib from C:\OpenCV\vs2005\lib\release (or debug) to C:\OpenCV\lib
Copy *.dll from C:\OpenCV\vs2005\bin\release to C:\OpenCV\bin
11. Now, reconfigure your application project. Include directories now “C:\OpenCV\include\opencv” instead of “C:\OpenCV\include
12. All libraries renamed from *.lib to *200.lib (cv.lib to cv200.lib) or *200d.lib for debug. Rename them, or change project settings.
PS if you need Python and still have a problem with cvpy:
From readme:
Known issues:
=============
1. Python 2.6 bindings for OpenCV are included within the package,
but not installed.
You can copy the subdirectory opencv/Python2.6/Lib/site-packages into
the respective directory of the Python installation.
Here is riseriyo explanation how he deal with python problem
PPS Comment by rise about vs2008 issue:
dll and manifest file version conflict in msvc 2008. the only way i was able to fix this was to completely uninstall msvc 2008 and then do a clean install w/o updating it with the sp1 packages.
see his blog and how he was troubleshooting (for days) the issue
PPPS As Niklas pointed out if you have omp.h not found error, that mean you forgot to turn off OpenMP in CMake.
That’s it. Project should compile now. If not you still have your old OpenCV installation
57 Comments
Sorry, the comment form is closed at this time.
Hi, I followed your instructions and it worked fine for debug, but when i tried running the solution in release mode, it gave 104 errors. i cleaned the release solution again and rebuilt it. i then received one error and 23 succeeded. Error is as follows. Do you have any suggestions? I’ll clean/rebuild again, and see if it succeeds in compiling successfully…but I am not sure why this is happening. Thnx. Rise
18> File “C:/OpenCV2.0/interfaces/python/gen.py”, line 290, in ?
18> if has_optional(args):
18> File “C:/OpenCV2.0/interfaces/python/gen.py”, line 103, in has_optional
18> return any([a.init for a in al])
18>NameError: global name ‘any’ is not defined
18>Project : error PRJ0019: A tool returned an error code from “Generating generated0.i”
18>Build log was saved at “file://c:\OpenCV2.0\VS2008\interfaces\python\cvpy.dir\Release\BuildLog.htm”
18>cvpy – 1 error(s), 0 warning(s)
Ok, so it seems that the function any() is not being recognized in python2.6 or visual studio 2008 for the project cv.py.
Seems you have problem with python. Anyway, if it was the only error, looks like non-python libraris and dll’s were compiled successfully. So if you don’t use python you don’t need it, if you use python – install/reinstall latest version of python.
hi, actually, last night i realized i have a different version of python (2.4.4) installed on my machine that is conflicting with the one (2.6) that comes with opencv2.0.
thnx a bunch. cheers, rise
Hi!
What did you mean with launch the solution??? (I’m new with openCV and Visual Studio, please help me T-T).
Just build solution, nothing more.
Hi!
I followed your instructions above.
But I can’t build the solution. I tried to build it with Visual Studio 6.0. I tried to build it in debug mode. Result: 10 error and 947 warnings. I don’t know what went wrong… Have you an idea what the problem is??
Greetings melle
I havn’t tried it with VS6, only VS 2005. Have you choosen building env correctly ? what errors you are getting ? Are you sure it’s not python related ?
Hi!
Yes I have choosen the right building env.
And I dont’t think that it is python related.
Is it possible to send you a txt-file with all errors and warnings?
I altough tried to build it with VS 2008. But with no success…
No. Just extract errors and post here.
Ok.
Can you tell if it is possible that the compiler from VS C++ 6.0 ist too old?
No idea. What error are you getting?
I hope you understand german. Because I have the german version of VS.
I get 10 Errors and 947 Warnings:
C:\OpenCV2.0\3rdparty\flann\algorithms\dist.h(35) : error C2871: ‘std’ : Existiert nicht oder ist kein Namespace
..\..\..\3rdparty\flann\util\random.h(108) : error C2374: ‘i’ : Neudefinition; Mehrfachinitialisierung
..\..\..\3rdparty\flann\algorithms\kmeans_index.h(201) : error C2065: ‘min’ : nichtdeklarierter Bezeichner
..\..\..\3rdparty\flann\util\random.h(108) : error C2374: ‘i’ : Neudefinition; Mehrfachinitialisierung
..\..\..\3rdparty\flann\util\random.h(102) : Siehe Deklaration von ‘i’
C:\OpenCV2.0\3rdparty\flann\util\random.h(108) : error C2374: ‘i’ : Neudefinition; Mehrfachinitialisierung
C:\OpenCV2.0\3rdparty\flann\util\random.cpp(44) : error C2039: ‘rand’ : Ist kein Element von ‘std’
C:\OpenCV2.0\3rdparty\flann\util\random.cpp(50) : error C2039: ‘rand’ : Ist kein Element von ‘std’
..\..\..\3rdparty\flann\util\random.h(108) : error C2374: ‘i’ : Neudefinition; Mehrfachinitialisierung
C:\OpenCV2.0\3rdparty\flann\util\saving.cpp(51) : error C2039: ‘fwrite’ : Ist kein Element von ‘std’
Are you aware of such wonderful service as Google Translate? For such simple texts it works very well.
You have infamous “using namespace std” error. It’s a known bug in VC6. Try remove this statements form flann libray where it sitting, sometimes it help (sometimes not). You may also have the same problem in the other libs.
Another problem (“i redefinition”) is that flann code can not be compiled under VC6 without modification – it use redefinition of loop variable, which is possible in VC8 but not VC6. If you want to compile with VC6 you have to modify all “bad” loops manually – for (int i= –> for(i=, though that may be not enough.
VS2008 should not have those problems.
Ok. I tried it with VS 2008. There it was successfully.
But I have an other question.
Do you know if the function cvSetCaptureProperty() is new implemented in OpenCV2.0?
Because in OpenCV1.1 it didn’t work right.
Don’t know, I’m using only epipolar geometry – Fundamental matrix, SVD, eignevectors etc. You may want to ask at OpenCV yahoo group, there should be someone to know such things there.
Hello,
I installed cmake2.6.4 and tried to create VS 2008 project file for the OpenCV2.0. But cmake is not creating VS project file in the specified build directory. I have followed the above instruction, but don;t know what is going wrong?. any help in this regard will be highly appreciated.
Hi,
I am seeing a strange problem when I perform the steps u’ve mentioned. I installed opencv 2.0 and cmake then restarted my laptop. Then I ran cmake as u’ve mentioned. But I see no visual studio solution in the folder I had given!!
I googled to find if somebody had faced this problem!! But none have. Any clue on what Im doing wrong.
I am using visual studio 2008 express edition
cmake : 2.6.4
Help me out
Is CMake failed on configure? Or on generate? It should tell if it failed and it should show error messages. May be someone at CMake forums/lists can help you.
Thanks for ya reply. It was late night n I was doin some stupid thing. It works completely well n gud.
It always better start fresh next morning
Thanks for posting this.
I was beating my head against a wall, tell I found this site!
The world is right again.
Thanks for posting this.
Little things spoils the life and we waste our time for solving major problems of others.
Hi,
I am currently using opencv 1.0 For one reason I have to switch to Opencv2.0(camera driver reason).I am using VC6.I did as you said using Cmake and chose Visual studio 6 for configuring.But I end up with 10 errors and 947 warnings Hence the .lib and .bin also did not get generated.Please help me out.My project is stuck
Also since using namespace std as is the problem in vc6.I tried build the .sln for VS2008 but I get several errors.One among them is cannot open include file “omp.h”
Sorry,cannot find include folder “omp.h” is the only error as of now leading to the failure of all 53 failed.
My installation don’t have such filer either
mirror what do you exactly mean
?
I don’t have omp.h in OpenCV. You probaly have some problem with VS2008 project. Try generate it again.
Hi.I did compile it now.But the release version did not get generated but only the debug did.The build ended with 52/53 success and 1 failure.How do I handle the failure.Also when I tried to execute the generated exe files in the debug folder it says the application failed to intialize because of improper configuration.What shall I do?Please advice..
What error are you getting ?
testvs2008.exe’: Loaded ‘C:\Documents and Settings\…..\My Documents\Visual Studio 2008\Projects\testvs2008\Debug\cxcore200d.dll’, Symbols loaded.
LDR: LdrpWalkImportDescriptor() failed to probe c:\Documents and Settings\…..\My Documents\Visual Studio 2008\Projects\testvs2008\Debug\cxcore200d.dll for its manifest, ntstatus 0xc0150002
Debugger:: An unhandled non-continuable exception was thrown during process load
The program ‘[1488] testvs2008.exe: Native’ has exited with code -1072365566 (0xc0150002).
I tried executing a sample program for camera capture but ends with thid.
Well i appears that it is not only me who could not get the exe files compiled on VS2008 for opencv but many others.It says “application failed to initialize because of incorrect config.Reinstalling may fix it”.I guess it is the problem with making opencv 2.0 work with VS2008 on Windows Xp ( I did fix the python26_d.lib problem by manually compiling and also fixed omp.h problem)But for some unknown and weird reason the exe files wont work.
hi, mirror2image and all,
if it helps, the reason why you cannot run the .exe files is because there is a .dll and manifest file version conflict in msvc 2008. the only way i was able to fix this was to completely uninstall msvc 2008 and then do a clean install w/o updating it with the sp1 packages.
see my blog and how i was troubleshooting (for days) the issue: http://program-per-day.blogspot.com/2009/11/cont-blues-of-msvc2008-dll-version.html
hope this helps others… cheers, rise
Ok,will try today rise..
But rise did you get the opencv solution without any warnings in MSVC2008?
hi, sri,
when i *built* opencv2.0 in msvc2008, i did not get an error msg about any .exe file. if you run debug or release mode, then msvc will state that an .exe file has not been found for opencv2.0. you don’t have to *run* opencv, you just have to *build* it in debug and release mode, respectively by choosing Build>Build Solution, after you have generated its configuration files for your system using cmake 2.4.6.
my last comment about the .dll and manifest files is another issue that one may run into, while testing some of the sample c files given with opencv2.0, if you have downloaded/installed the service pack 1 (sp1) for msvc2008, the c++ redistributables package setup, and/or the c++ redistributable package update. See blog http://program-per-day.blogspot.com/2009/11/cont-blues-of-msvc2008-dll-version.html for information about these packages.
hope this helps you, sri. cheers, rise
Hello,
I’ trying to compile OpenCV 2.0 using VC++ 6.0 but a lot of problems.
1.) First the “using namespace std”: Solved deleting the “std::”.
2.) the “i redefinition” and “k redefinition: Solved deleting the definition.
Now, here the new problem:
C:\OpenCV2.0\3rdparty\flann\algorithms\kdtree_index.h(648) : warning C4512: ‘KDTreeIndex’ : assignment operator could not be generated
C:\OpenCV2.0\3rdparty\flann\algorithms\kdtree_index.h(60) : see declaration of ‘KDTreeIndex’
C:\OpenCV2.0\3rdparty\flann\algorithms\kdtree_index.h(358) : error C2275: ‘KDTreeIndex::TreeSt’ : illegal use of this type as an expression
C:\OpenCV2.0\3rdparty\flann\algorithms\kdtree_index.h(358) : error C2059: syntax error : ‘)’
C:\OpenCV2.0\3rdparty\flann\algorithms\kdtree_index.h(382) : error C2275: ‘KDTreeIndex::TreeSt’ : illegal use of this type as an expression
C:\OpenCV2.0\3rdparty\flann\algorithms\kdtree_index.h(382) : error C2059: syntax error : ‘)’
C:\OpenCV2.0\3rdparty\flann\algorithms\kdtree_index.h(411) : error C2065: ‘min’ : undeclared identifier
Any ideas please?
Thanks
Joe
To get around the omp.h error, reconfigure the CMAKE to disable the OPENMP.
Tick off the ENABLE_OPENMP in CMAKE
Guys I really need your help installing this beast on my pc. Clearly I have an ffmpeg issue but I don’t understand what I have to modify. I downloaded the source of ffmpeg 0.5 and replaced some files, played around sith things in logical and illogical ways and get nowhere. Here is my issue:
Linux users have the option to use swscale-dev but I don’t have the option
in cmake, How vital is ffmpeg support for someone that just wants to
learn?
Compiling…
ffopencv.cpp
C:\OpenCV\src\highgui\cvcap_ffmpeg.cpp(1095) : error C3861: ‘img_convert’:
identifier not found
relevant to this segment of code:
#if !defined(HAVE_FFMPEG_SWSCALE)
// convert to the color format needed by the codec
if( img_convert((AVPicture *)picture, c->pix_fmt,
(AVPicture *)input_picture, (PixelFormat)input_pix_fmt,
image->width, image->height) —— Build started: Project: opencv_ffmpeg, Configuration: Debug x64
——
1>Compiling…
1>ffopencv.cpp
1>Compiling manifest to resources…
1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>Linking…
1> Creating library ..\..\lib\Debug\opencv_ffmpeg200d.lib and object
..\..\lib\Debug\opencv_ffmpeg200d.exp
1>ffopencv.obj : error LNK2019: unresolved external symbol
av_close_input_file referenced in function “public: virtual void __cdecl
CvCapture_FFMPEG::close(void)” (?close@CvCapture_FFMPEG@@UEAAXXZ)
1>ffopencv.obj : error LNK2019: unresolved external symbol avcodec_close
referenced in function “public: virtual void __cdecl
CvCapture_FFMPEG::close(void)” (?close@CvCapture_FFMPEG@@UEAAXXZ)
1>ffopencv.obj : error LNK2019: unresolved external symbol av_free
referenced in function “public: virtual void __cdecl
…..
1>ffopencv.obj : error LNK2019: unresolved external symbol av_new_stream
referenced in function “struct AVStream * __cdecl
icv_add_video_stream_FFMPEG(struct AVFormatContext *,enum
CodecID,int,int,int,double,int)”
(?icv_add_video_stream_FFMPEG@@YAPEAUAVStream@@PEAUAVFormatContext@@W4Codec
ID@@HHHNH@Z)
1>..\..\bin\Debug\opencv_ffmpeg200d.dll : fatal error LNK1120: 36
unresolved externals
1>Build log was saved at
“file://c:\opencv2\MS\interfaces\ffopencv\opencv_ffmpeg.dir\Debug\BuildLog.
htm”
1>opencv_ffmpeg – 37 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 5 up-to-date, 0 skipped
==========
As I understand default windows OpenCV installation doesn’t use ffmpeg, it use dshow instead. Solution generated by cmake doesn’t even include cvcap_ffmpeg.cpp (at least in my cfg) it has cvcap_dshow.cpp . If for some reason you want use ffmpeg instead of dshow that could be non-trivial, you should probably ask Linux users.
mirror2image,
Thanks for the advice. I just decided, for the time being, to not build the ffmpeg section. It compiled nicely in release and the examples are working. Time to crack open the O’reilly book and hack away
For those that are like me that are noobyish in this whole process this is what I did to make it work:
On win7 x64 ms 2008 you need to download python2.6.
Then follow the instructions above. Once in CMake though, uncheck Enable_openMP and set the correct directory for your python install.
In VS2008 remove the ffmpeg project from the solution explorer, change from debug to release mode, and build the solution. Worked for me!
helo dear
Can any one tell me how to add libraries in visual studio 2006 of opencv
Waiting 4 rpely
helo dear
Can any one tell me how to add libraries in visual studio 2006 of opencv
Waiting 4 rpely
regards
Hey,
I tried this in VS2008 but I’m getting the following errors:
1>—— Build started: Project: highgui, Configuration: Debug Win32 ——
1>Compiling…
1>cvcap_dshow.cpp
1>..\..\..\src\highgui\cvcap_dshow.cpp(45) : fatal error C1083: Cannot open include file: ‘videoinput.h’: No such file or directory
1>Build log was saved at “file://c:\OpenCV2.0\VS2008\src\highgui\highgui.dir\Debug\BuildLog.htm”
1>highgui – 1 error(s), 0 warning(s)
2>—— Build started: Project: performance, Configuration: Debug Win32 ——
3>—— Build started: Project: cvaux, Configuration: Debug Win32 ——
2>Linking…
3>Linking…
2>LINK : fatal error LNK1104: cannot open file ‘..\..\lib\Debug\highgui200d.lib’
3>LINK : fatal error LNK1104: cannot open file ‘..\..\lib\Debug\highgui200d.lib’
2>Build log was saved at “file://c:\OpenCV2.0\VS2008\apps\haartraining\performance.dir\Debug\BuildLog.htm”
2>performance – 1 error(s), 0 warning(s)
3>Build log was saved at “file://c:\OpenCV2.0\VS2008\src\cvaux\cvaux.dir\Debug\BuildLog.htm”
3>cvaux – 1 error(s), 0 warning(s)
4>—— Build started: Project: traincascade, Configuration: Debug Win32 ——
5>—— Build started: Project: haartraining, Configuration: Debug Win32 ——
4>Linking…
4>LINK : fatal error LNK1104: cannot open file ‘..\..\lib\Debug\highgui200d.lib’
5>Linking…
4>Build log was saved at “file://c:\OpenCV2.0\VS2008\apps\traincascade\traincascade.dir\Debug\BuildLog.htm”
5>LINK : fatal error LNK1104: cannot open file ‘..\..\lib\Debug\highgui200d.lib’
4>traincascade – 1 error(s), 0 warning(s)
5>Build log was saved at “file://c:\OpenCV2.0\VS2008\apps\haartraining\haartraining.dir\Debug\BuildLog.htm”
5>haartraining – 1 error(s), 0 warning(s)
6>—— Build started: Project: createsamples, Configuration: Debug Win32 ——
6>Linking…
6>LINK : fatal error LNK1104: cannot open file ‘..\..\lib\Debug\highgui200d.lib’
6>Build log was saved at “file://c:\OpenCV2.0\VS2008\apps\haartraining\createsamples.dir\Debug\BuildLog.htm”
6>createsamples – 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 6 failed, 10 up-to-date, 0 skipped ==========
Can you help me please?
Hi -
I would like to thank you, it did work well for me !
I’m using Visual Studio 2008 and OpenCV through C++ everything went fine. thanks again
[...] OpenCV with VS 2005 Filed under: Computer — Tags: CMake, OpenCV, OpenCV 2, Visual Studio, VS 2005 — Yeti @ 16:50 Since I’ve had some trouble getting OpenCV 2.00 to work with my Visual Studio 2005 installation, I’ld like to share the following post by Sergey Ten. [...]
Pingback by OpenCV with VS 2005 « Ropes I Know | 31, January, 2010
je veux installer OpenCV 2.0 en visual studio sous windows donc je suivre toutes les étapes. mais il ya une erreur :
Build started: Project: essai, Configuration: Debug Win32 ——
Linking…
LINK : fatal error LNK1104: cannot open file ‘cv.lib’
Build log was saved at “file://c:\Documents and Settings\tarak\Mes documents\Visual Studio 2008\Projects\essai\essai\Debug\BuildLog.htm”
essai – 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
veuillez vous me donner une solution.
Same problem as above, but I’ve specified the lib file as cv200 anyone know a fix?
Never mind, solved, forgot to put in the .lib at end of library name.
I followed the above steps with VS2005 and Open Cv2.0. But neither do i get any .sln file nor bin ,debug ,release folder.Can any one please help me out of it?
HI!!
I am new to openCV and computer science also. I am trying to install Opencv. i configured and generated using Cmake2.8. but what should i do now? I tried to build using VC++ 2008. but its giving error that omp.h file is missing. Please help!
@yogesh as stated by Niklas above
“To get around the omp.h error, reconfigure the CMAKE to disable the OPENMP.
Tick off the ENABLE_OPENMP in CMAKE
Comment by Niklas | 2, December, 2009″
Wow, what a terrible hassle.
Why the build lib is so big. Mine is more than 50M for static library. Is it normal.
Thank you,
Hi there
I followed all the steps of the instalation procedure but I’m having the following error, when I compile my source code:
highgui200.dll not found. Re-instalation could solve the problem.
I wait for your answers
Ivan
Guys, make your lives easier and avoid the headache by switching to VS2008 and installing the latest version of OpenCV that comes ready to work with VS2008 without any problems. The file is: OpenCV-2.1.0-win32-vs2008.exe.. After that just add the src, include and libs folders and link your project to the lib files inside the lib folder.. that’s it!
maybe help:
install opencv 2.0 to visual c++ 2010 Express, here: http://arie-fardiansyah.blogspot.com/2010/09/install-opencv-20-ke-visual-c-2010.html
install opencv 2.0 to Dev-C++ 4.9.9.2, here: http://arie-fardiansyah.blogspot.com/2010/09/install-opencv-20-ke-dev-c-4992.html