Install openCV 2.4 for C / C ++ for Visual Studio

I have been trying all day to install OpenCV (versions 2.4.1 and 2.4.2) for Visual Studio 2010 on Windows 7 for C / C ++.

I follow this guide: http://docs.opencv.org/trunk/doc/tutorials/introduction/windows_install/windows_install.html

I skipped installing third-party software (except for python 2.7 and zlib from here: http://gnuwin32.sourceforge.net/packages/zlib.htm ).

I run cmake, then open openCV.sln from the openCV build directory, wait for the visual studio to load, and then create it. Visual studio gives 200 hundred errors, which are repeated only two times many times:

error C1083: cannot open include file: 'unistd.h': no ​​such file or directory

error LNK1104: cannot open file '.... \ lib \ Debug \ opencv_core241d.lib'

The "OpenCV build directory" / bin / Release does not contain any * .exe file, there are a lot of * .pdb files, among which I see contours.pdb. The tutorial says that I should see contours.exe.

Since there are no * .exe files, I understand that the two errors that I get during the build are critical. I would be grateful for any ideas that could help me solve them.

+6
source share
3 answers

The following interpretation of the assembly steps should help you in creating it:

  • Install cmake - this is necessary for all platforms

  • cd into the extracted directory and create a new directory named release (or any other name)

  • In this directory, run cmake ..

  • You should find the OpenCV.sln file in the release directory.

  • Open it with Visual Stuido and run the build.

  • Go ahead and enjoy Opencv

+4
source

I ran into some difficulties: the documentation is a bit outdated.

This solution is based on this tutorial: http://opencv.willowgarage.com/wiki/VisualC%2B%2B_VS2010_CMake

Here are the exact steps I took to get the opensv 2.4.2 hello world example working with Visual C ++ 2010 Express:

Take the source code

Download opencv.

Extract opencv to C: \

Binary creation

Download cmake. Open cmake gui ..

Where is the source code: C: / opencv

Where to build binary files: C: / opencv / build

Click "Customize" - for the generator, select Visual Studio 10 Click "Create".

In C: \ opencv \ build you should see OpenCV.sln.

Open the solution file using VS C ++ Express and create it.

Setting up the hello world project

Create a new project in VS. Select a console application and check the boxes with precompiled headers. Right-click the solution file and select properties.

In the VC ++ Directories window, add the following:

Include directories: C: \ opencv \ build \ include; C: \ opencv \ build \ include \ opencv; C: \ opencv \ build \ include \ opencv2

Library Directories: C: \ OpenCV \ Build \ Lib \ Debug

Sources: C: \ OpenCV \ build \ enable

In C ++ β†’ Linker β†’ Input add the following additional dependencies:

 opencv_core242d.lib opencv_highgui242d.lib 

Hello World Content

Modify the content as suggested in the tutorial to:

 #include "stdafx.h" #include <cv.h> #include <cxcore.h> #include <highgui.h> int _tmain(int argc, _TCHAR* argv[]) { IplImage *img = cvLoadImage("funny-pictures-cat-goes-pew.jpg"); cvNamedWindow("Image:",1); cvShowImage("image:",img); cvWaitKey(); cvDestroyWindow("Image:"); cvReleaseImage(&img); return 0; } 

Place the image (or any image) in the project directory.

Now create and delete Debug, and it should work. Hope this helps someone.

+2
source

I can not put a comment, so I have to answer as an answer.

@ go4sri I followed what you said and compiled OpenCV with visual studio 2010, but I don’t know how to configure the properties file and which folder to put in the library directory, include the directory ... I need help.

At the moment I put:

C: \ opencv \ build \ include in the Include directory

C: \ opencv \ Release \ lib \ Debugging in the library directory. (I embed in the Release folder)

But I get an unresolved external character.

  error LNK2019: unresolved external symbol "public: static class cv::MatExpr __cdecl cv::Mat::zeros(int,int,int)" ( ?zeros@Mat @ cv@ @ SA?AVMatExpr@2 @ HHH@Z ) referenced in function "public: void __thiscall CtestDlg::OnBnClickedOk(void)" ( ?OnBnClickedOk@CtestDlg @@QAEXXZ) 

EDIT 1:

I fixed the problem by adding .lib to the input linkers-> input-> additional dependencies, but now I have a different problem. This tells me that he cannot find the dll opencv_core242d.dll.

EDIT 2:

Putting the entire dll in a release (for release) or debug (for debug dll) solves the problem, but I don't understand why I should do this. He can't find himself where dlls

+1
source

Source: https://habr.com/ru/post/920709/


All Articles