Build Opencv 3.2 fails on Windows 8.1 with VS2013

asked 2017-01-16 17:05:33 -0500

supersushi gravatar image

updated 2017-01-17 17:37:05 -0500

Building Opencv-3.2.0 failed on my Windows 8.1 VM, using cmake 3.5.2 and visual studio 2013:

First, Visual Studio fails without showing any helpful message, but after digging I found out cmake/cl2cpp.cmake crashes every time. I fixed it by changing this line:

string(REGEX REPLACE "/\\*([^*]/|\\*[^/]|[^*/])*\\*/" ""   lines "${lines}") # multiline comments

to:

string(REGEX REPLACE "/\\*[^\n]*\n" ""   lines "${lines}") # multiline comments
string(REGEX REPLACE "[^\n]+\\*/\n" ""   lines "${lines}") # multiline comments

But ok, that could be a CMake bug. After that, I'm getting the following errors:

7>E:\src\Components\opencv\src\opencv\modules\core\src\parallel.cpp(554): error C2065: 'SYSTEM_INFO' : undeclared identifier 7>E:\src\Components\opencv\src\opencv\modules\core\src\parallel.cpp(554): error C2146: syntax error : missing ';' before identifier 'sysinfo' 7>E:\src\Components\opencv\src\opencv\modules\core\src\parallel.cpp(554): error C2065: 'sysinfo' : undeclared identifier 7>E:\src\Components\opencv\src\opencv\modules\core\src\parallel.cpp(558): error C2065: 'sysinfo' : undeclared identifier 7>E:\src\Components\opencv\src\opencv\modules\core\src\parallel.cpp(558): error C3861: 'GetSystemInfo': identifier not found 7>E:\src\Components\opencv\src\opencv\modules\core\src\parallel.cpp(561): error C2065: 'sysinfo' : undeclared identifier 7>E:\src\Components\opencv\src\opencv\modules\core\src\parallel.cpp(561): error C2228: left of '.dwNumberOfProcessors' must have class/struct/union 7> type is 'unknown-type'

The code it is referring to in parallel.cpp:

#if defined WIN32 || defined _WIN32
    SYSTEM_INFO sysinfo;

And at the top of that file,

#if defined WIN32 || defined WINCE
    #include <windows.h>

This error is fixed by checking for _WIN32 as well:

#if defined WIN32 || defined _WIN32 || defined WINCE
    #include <windows.h>

I finally got the whole build to succeed after adding || defined _WIN32 to a bunch of cpp files.

My question basically is: am I doing something wrong or is this a bug that should be reported?

EDIT: My build command is:

'cmake.exe', '-G', 'Visual Studio 12 Win64',
'-DBUILD_WITH_STATIC_CRT=OFF',
'-DBUILD_SHARED_LIBS=ON',
'-DCMAKE_CXX_FLAGS=/MP',
'-DCMAKE_C_FLAGS=/MP'
'-DWITH_1394=OFF',
'-DWITH_FFMPEG=OFF',
'-DWITH_EIGEN=ON',
'-DWITH_OPENCL=ON',
'-DWITH_CUDA=ON',
'-DWITH_IPP=ON',
'-DWITH_TBB=ON',
'-DWITH_TIFF=ON',
'-DWITH_OPENCL=ON',
'-DBUILD_TBB=OFF',
'-DBUILD_opencv_apps=OFF',
'-DBUILD_DOCS=OFF',
'-DBUILD_PERF_TESTS=OFF',
'-DBUILD_TESTS=OFF',
'-DBUILD_ZLIB=OFF',
'-DENABLE_SSE41=ON',
'-DENABLE_AVX2=OFF',
'-DTBB_INCLUDE_DIR=.../include',
'-DCUDA_TOOLKIT_ROOT_DIR=...',
'-DINSTALL_CREATE_DISTRIB=OFF',
'-DBUILD_opencv_world=OFF'
edit retag flag offensive close merge delete

Comments

1

May be I'm wrong but I think there is no problem building opencv using VS 2013. Build bot opencv still uses VS 2013 for win 7 x64 platform. delete all your changes. Delete cmakecache.txt. Command used in buildbot is

cmake -G"Visual Studio 12 Win64" -DOPENCV_ENABLE_NONFREE=ON -DBUILD_SHARED_LIBS=ON -DBUILD_PERF_TESTS=ON -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DBUILD_DOCS=OFF -DWITH_OPENCL=OFF -DWITH_IPP=ON -DWITH_CUDA=OFF

Try this command

LBerger gravatar imageLBerger ( 2017-01-17 01:53:26 -0500 )edit

Thanks, @LBerger. I tried a clean build (deleted everything in the build tree) but the problems remain.

Due to the high number of possible combinations, what works for the buildbot might not work for me. I'm probably using a different version of cmake, I'm using TBB, CUDA, I'm disabling a bunch of stuff. See my edit in the post.

So clearly my problem is that WIN32 is not defined. I can see it in visual studio because the code inside the #ifdef is greyed out. Any ideas? Thanks for your help.

supersushi gravatar imagesupersushi ( 2017-01-17 17:35:22 -0500 )edit

I have just build using vs 2013 opencv 3.2.0-dev and there is no problem windows 2010). Your error is SYSINFO. It is defined in c:\Program Files (x86)\Windows Kits\8.1\Include\um\sysinfoapi.h Have you got Windows kits ?

LBerger gravatar imageLBerger ( 2017-01-18 01:22:04 -0500 )edit

Yes I have got Windows Kit. Otherwise it wouldn't have worked when I added || defined _WIN32.

supersushi gravatar imagesupersushi ( 2017-01-18 21:28:59 -0500 )edit

I build opencv 3.2.0 with vs 2012 on windows 7 with all samples. It works. I don't think it's a bug. may be I'm wrong. Of course you can report an issue.

In my vs 2013 generator is cmake -G "Visual Studio 12 2013 Win64" not like in buildbot

LBerger gravatar imageLBerger ( 2017-01-19 01:45:43 -0500 )edit