Home > Net >  Installing OpenCV in C Visual Studio: How can I fix these linker errors that occur although I foll
Installing OpenCV in C Visual Studio: How can I fix these linker errors that occur although I foll

Time:12-24

I have tried downloading the C OpenCV Library to Visual Studio 2019. When trying to compile my code, I am getting these errors:

1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(40,9): error C4430: missing type specifier - int assumed. Note: C   does not support default-int
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(40,19): error C2059: syntax error: 'constant'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(42,1): error C2143: syntax error: missing ';' before '{'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(42,1): error C2447: '{': missing function header (old-style formal list?)
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,62): error C2039: 'has_parenthesis_operator': is not a member of 'cv::sfinae'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(39): message : see declaration of 'cv::sfinae'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,1): error C2065: 'has_parenthesis_operator': undeclared identifier
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,1): error C2977: 'std::enable_if': too many template arguments
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xtr1common(46): message : see declaration of 'std::enable_if'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,117): error C2955: 'std::enable_if': use of class template requires template argument list
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xtr1common(46): message : see declaration of 'std::enable_if'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,131): error C2988: unrecognizable template declaration/definition
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,131): error C2059: syntax error: '>'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(69,11): error C2988: unrecognizable template declaration/definition
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(69,11): error C2059: syntax error: 'public'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(69,1): error C2143: syntax error: missing ';' before '{'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(69,1): error C2447: '{': missing function header (old-style formal list?)
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(80,26): error C4430: missing type specifier - int assumed. Note: C   does not support default-int
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(140): message : see reference to class template instantiation 'cv::Ptr<T>' being compiled
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(80,35): error C2059: syntax error: 'constant'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(80,26): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(140,1): fatal error C1903: unable to recover from previous error(s); stopping compilation

I suspect it is a linker errors, so I went ahead and made sure I have included all the dependencies and libraries, and I have done as follows, I included the opencv libraries and the library directories and added the additional dependencies:

yet I am still getting the same errors. Does anyone know how I can get rid of them? Thank you for your help!

Link to the images: https://imgur.com/a/M1UV7yL

CodePudding user response:

Update: It was fixed by creating a new file and copying the contents of the file that created the errors. I don't know why, but it worked for me and might work for you.

Good Luck :)

  • Related