Ask Your Question

Revision history [back]

OpenCV 3.4.1, first tutorial won't build

This is on Windows 10 x64, with Visual Studio 2017 and opencv 3.4.1.

I installed opencv via this guide from the docs, changing the git lines to add --branch 3.4 and changing the Visual Studio version to Visual Studio 15 2017. Everything appears to build fine, and I add opencv to path and make the local property pages per this page from the guide.

There are no red underlines or other indications that anything is wrong in the editor view, but upon trying to build the sample code given, more or less everything is an error. The build output is as follows:

1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------ 1>ConsoleApplication1.cpp

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(7): error C2871: 'cv': a namespace with this name does not exist

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(13): error C2065: 'cout': undeclared identifier

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(13): error C2065: 'endl': undeclared identifier

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(16): error C2065: 'Mat': undeclared identifier

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(16): error C2146: syntax error: missing ';' before identifier 'image'

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(16): error C2065: 'image': undeclared identifier

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(17): error C2065: 'image': undeclared identifier

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(17): error C2065: 'IMREAD_COLOR': undeclared identifier

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(17): error C3861: 'imread': identifier not found

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(18): error C2065: 'image': undeclared identifier

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(18): error C2228: left of '.empty' must have class/struct/union

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(18): note: type is 'unknown-type'

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(20): error C2065: 'cout': undeclared identifier

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(20): error C2039: 'endl': is not a member of 'std'

1>c:\users\jakob\source\repos\consoleapplication1\predefined c++ types (compiler internal)(238): note: see declaration of 'std'

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(20): error C2065: 'endl': undeclared identifier

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(23): error C2065: 'WINDOW_AUTOSIZE': undeclared identifier

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(23): error C3861: 'namedWindow': identifier not found

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(24): error C2065: 'image': undeclared identifier

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(24): error C3861: 'imshow': identifier not found

1>c:\users\jakob\source\repos\consoleapplication1\consoleapplication1.cpp(25): error C3861: 'waitKey': identifier not found

1>Done building project "ConsoleApplication1.vcxproj" -- FAILED.

VS clearly sees the headers, since it doesn't give the red underlines to indicate that they're not found. Still, something is clearly very wrong. I couldn't find anything by searching here, sorry if I missed something.