Home > Software design >  How to Add Library to Visual Studio - OpenCV
How to Add Library to Visual Studio - OpenCV

Time:01-30

Im trying to add OpenCV to Visual Studio, and afer following the instructions from this video: https://www.youtube.com/watch?v=unSce_GPwto&ab_channel=BoostMyTool , it returned that it was not built succesfuly.

To start off, what i have already done:

  • I added Path to Enviroment Variables

  • added the path "C:\Users\Uporabnik\Documents\Library\opencv\build\ include" to project/properties/c#c /general/addittional include directories

  • added the path "C:\Users\Uporabnik\Documents\Library\opencv\build\x64\vc15\ lib" to project/properties/linker/general/addittional library directories

  • added "opencv_world460.lib" to project/properties/linker/input/addittional dependencies

when all was done, i ran the build solution and it returnes not succesfull. im used to python on PyCharm, where adding libraries is as easy ass pressing add library, so this has been an annoying experiance so far

the error message after "build/build solution":

Build started...
1>------ Build started: Project: hhh, Configuration: Release x64 ------
1>hhh.cpp
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\hhh.cpp(11,39): error C2065: 'CV_CAP_PROP_FRAME_COUNT': undeclared identifier
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\hhh.cpp(12,45): error C2065: 'CV_CAP_PROP_FRAME_COUNT': undeclared identifier
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\hhh.cpp(20,40): error C2065: 'CV_CAP_PROP_FRAME_WIDTH': undeclared identifier
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\hhh.cpp(20,79): error C2065: 'CV_CAP_PROP_FRAME_HEIGHT': undeclared identifier
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\hhh.cpp(21,46): error C2065: 'CV_CAP_PROP_FRAME_WIDTH': undeclared identifier
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\hhh.cpp(21,88): error C2065: 'CV_CAP_PROP_FRAME_HEIGHT': undeclared identifier
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\hhh.cpp(23,62): error C3861: 'CV_FOURCC': identifier not found
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\hhh.cpp(53,1): error C2018: unknown character '0x60'
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\hhh.cpp(53,2): error C2018: unknown character '0x60'
1>main.cpp
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\main.cpp(11,39): error C2065: 'CV_CAP_PROP_FRAME_COUNT': undeclared identifier
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\main.cpp(12,45): error C2065: 'CV_CAP_PROP_FRAME_COUNT': undeclared identifier
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\main.cpp(20,40): error C2065: 'CV_CAP_PROP_FRAME_WIDTH': undeclared identifier
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\main.cpp(20,79): error C2065: 'CV_CAP_PROP_FRAME_HEIGHT': undeclared identifier
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\main.cpp(21,46): error C2065: 'CV_CAP_PROP_FRAME_WIDTH': undeclared identifier
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\main.cpp(21,88): error C2065: 'CV_CAP_PROP_FRAME_HEIGHT': undeclared identifier
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\main.cpp(23,62): error C3861: 'CV_FOURCC': identifier not found
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\main.cpp(53,1): error C2018: unknown character '0x60'
1>C:\Users\Uporabnik\Desktop\C#\hhh\hhh\main.cpp(53,2): error C2018: unknown character '0x60'
1>Done building project "hhh.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Elapsed 00:04,338 ==========

CodePudding user response:

Well, that's an error compiling, not a linker error, so it can be relatively few things.

  1. Verify that hhh.cpp and main.cpp include the correct OpenCV header(s).
  2. Verify those headers are actually in C:\Users\Uporabnik\Documents\Library\opencv\build\includeor are in folders accessible by relative paths rooted there that correspond to the relative paths in your include directives.
  3. Verify you have added that path to "Additional Include Directories" in the properties of the configuration you are trying to build.

Without additional information my guess would be your problem is 3. The "configuration" in Visual Studio is typically a pair of parameters, either Debug or Release along with the architecture, x86 (often displayed as "Win32" in VS) or x64. I can see from the error messages you are trying to build "Release x64".

Go into properties and make sure you have made the addition to "Additional Include Directories" in the configuration "Release x64". It is an easy mistake to make to accidently set properties only for Debug or only for x86, etc.

  • Related