[C++] [Opencv] [vs2015] Environment configuration

every blog every motto: You will never know unless you try

0. Preface

The configuration on the Internet is mostly old, here is a simple summary of the opencv configuration, temporarily recording a method, and subsequent additional
instructions:

  • This article is added in the property page, and the following references are slightly different in the property manager. How to try later
  • There is also cmake method, follow-up supplement
  • The distinction and usefulness of dynamic/static link library, follow-up supplement

1. Text

1.1 Method 1:

1.1.0 Prerequisite knowledge

VC vs version
vc11 visual studio 2012
vc14 visual studio 2015
vc15 visual studio 2017
  • The header file of the library is needed when compiling, include (.h file)
  • Use static link library (.lib) when linking
  • Dynamic link library (.dll or .exe) used during runtime

1.1.1 Download

opencv official link

  • Documentation Program related documentation
  • Sources is the source code of opencv
  • windows contains source code and libraries compiled with source code

Insert picture description here

1.1.2 Unzip

Unzip the downloaded file to the specified directory
Insert picture description here
Insert picture description here

1.1.3 Configuration environment

This computer -> Properties -> Advanced Settings -> Environment Variables Change
Insert picture description here
Insert picture description here
Insert picture description here
the path

F:\public\package\c plus plus\opencv\build\x64\vc14\bin

Add to it
Insert picture description here

1.1.4 vs2015 new project

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

1.1.5 Configuration

View->Property Page
Insert picture description here

1. vc++ directory

Add in "include directory"

F:\public\package\c plus plus\opencv\build\include
F:\public\package\c plus plus\opencv\build\include\opencv2

Insert picture description here

Add in "Library Directory"

F:\public\package\c plus plus\opencv\build\x64\vc14\lib

Insert picture description here

After adding:
Insert picture description here

2. Linker

Linker -> Input -> Additional dependencies, add the following

opencv_world440.lib
opencv_world440d.lib

Source of the above name:
Insert picture description here
add as follows:
Insert picture description here

3. Supplement (There may be errors if you do not do this step)

Copy the following files to the path of C:\Windows\System32
Insert picture description here
After copying:
Insert picture description here

1.1.4 Test

code show as below:

#include <opencv2/opencv.hpp> //头文件
using namespace cv; //包含cv命名空间

int main()
{
    
    
	// 【1】读入一张图片
	Mat img = imread("1.jpg");
	// 【2】在窗口中显示载入的图片
	imshow("【载入的图片】", img);
	// 【3】等待6000 ms后窗口自动关闭
	waitKey(6000);
}

Insert picture description here
result:
Insert picture description here

references

[1] http://blog.sina.com.cn/s/blog_53ec9d910102ykxu.html
[2] https://blog.csdn.net/chenlin41204050/article/details/82559780
[3] https://www.cnblogs.com/YiYA-blog/p/10296224.html
[4] https://blog.csdn.net/qq_40515692/article/details/81042303
[5] https://zhuanlan.zhihu.com/p/129839844
[6] https://blog.csdn.net/sinat_39061823/article/details/80723096
[7] https://blog.csdn.net/smilife_/article/details/89244189
[8] https://www.cnblogs.com/white-L/p/11285097.html
[9] https://www.jianshu.com/p/74107b6f0ce9
[10] https://blog.csdn.net/github_34777264/article/details/80834876
[11] https://www.cnblogs.com/ganjiqi/p/8651350.html
[12] https://blog.csdn.net/investspace/article/details/97264324
[13] https://blog.csdn.net/qq_34741911/article/details/83858176
[14] https://www.cnblogs.com/tansuoxinweilai/p/10424361.html

Guess you like

Origin blog.csdn.net/weixin_39190382/article/details/108432880