我正在尝试使用cmake-gui在Windows中为Mingw64编译最新版本的opencv 3,并且在编译源文件时遇到了一些错误。
到目前为止,我在阅读其他人的解决方案时遇到了许多问题,但是遇到了一个我无法解决的问题。我一直无法编译highgui库,如果我不去编译的话,编译就可以了。
我使用了Mingw 64中的常规mingw32-make
。
这是错误日志,它很长而且很麻烦,但我希望它可以提供一些见解:
Scanning dependencies of target opencv_highgui
[ 83%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window.cpp.obj
[ 83%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/roiSelector.cpp.obj
[ 83%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_w32.cpp.obj
In file included from C:\opencv\sources\modules\highgui\src\window_w32.cpp:56:
C:/mingw/mingw64/x86_64-w64-mingw32/include/commctrl.h:8: error: unterminated #ifndef
#ifndef _INC_COMMCTRL
C:\opencv\sources\modules\highgui\src\window_w32.cpp: In function 'void icvLoadWindowPos(const char*, CvRect&)':
C:\opencv\sources\modules\highgui\src\window_w32.cpp:311:46: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
strcpy( szKey, 1024, icvWindowPosRootKey );
^
C:\opencv\sources\modules\highgui\src\window_w32.cpp:311:46: error: too many arguments to function 'char* strcpy(char*, const char*)'
In file included from C:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/cstring:42,
from C:/opencv/sources/modules/core/include/opencv2/core/cvstd.hpp:53,
from C:/opencv/sources/modules/core/include/opencv2/core/base.hpp:58,
from C:/opencv/sources/modules/core/include/opencv2/core.hpp:54,
from C:/opencv/sources/modules/highgui/include/opencv2/highgui.hpp:46,
from C:\opencv\sources\modules\highgui\src\precomp.hpp:45,
from C:\opencv\sources\modules\highgui\src\window_w32.cpp:42:
C:/mingw/mingw64/x86_64-w64-mingw32/include/string.h:61:18: note: declared here
char * __cdecl strcpy(char * __restrict__ _Dest,const char * __restrict__ _Source);
^~~~~~
C:\opencv\sources\modules\highgui\src\window_w32.cpp:312:31: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
strcat( szKey, 1024, name );
^
C:\opencv\sources\modules\highgui\src\window_w32.cpp:312:31: error: too many arguments to function 'char* strcat(char*, const char*)'
In file included from C:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/cstring:42,
from C:/opencv/sources/modules/core/include/opencv2/core/cvstd.hpp:53,
from C:/opencv/sources/modules/core/include/opencv2/core/base.hpp:58,
from C:/opencv/sources/modules/core/include/opencv2/core.hpp:54,
from C:/opencv/sources/modules/highgui/include/opencv2/highgui.hpp:46,
from C:\opencv\sources\modules\highgui\src\precomp.hpp:45,
from C:\opencv\sources\modules\highgui\src\window_w32.cpp:42:
C:/mingw/mingw64/x86_64-w64-mingw32/include/string.h:62:18: note: declared here
char * __cdecl strcat(char * __restrict__ _Dest,const char * __restrict__ _Source);
^~~~~~
C:\opencv\sources\modules\highgui\src\window_w32.cpp: In function 'void icvSaveWindowPos(const char*, CvRect)':
C:\opencv\sources\modules\highgui\src\window_w32.cpp:372:46: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
strcpy( szKey, 1024, icvWindowPosRootKey );
^
C:\opencv\sources\modules\highgui\src\window_w32.cpp:372:46: error: too many arguments to function 'char* strcpy(char*, const char*)'
In file included from C:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/cstring:42,
from C:/opencv/sources/modules/core/include/opencv2/core/cvstd.hpp:53,
from C:/opencv/sources/modules/core/include/opencv2/core/base.hpp:58,
from C:/opencv/sources/modules/core/include/opencv2/core.hpp:54,
from C:/opencv/sources/modules/highgui/include/opencv2/highgui.hpp:46,
from C:\opencv\sources\modules\highgui\src\precomp.hpp:45,
from C:\opencv\sources\modules\highgui\src\window_w32.cpp:42:
C:/mingw/mingw64/x86_64-w64-mingw32/include/string.h:61:18: note: declared here
char * __cdecl strcpy(char * __restrict__ _Dest,const char * __restrict__ _Source);
^~~~~~
C:\opencv\sources\modules\highgui\src\window_w32.cpp:373:31: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
strcat( szKey, 1024, name );
^
C:\opencv\sources\modules\highgui\src\window_w32.cpp:373:31: error: too many arguments to function 'char* strcat(char*, const char*)'
In file included from C:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/cstring:42,
from C:/opencv/sources/modules/core/include/opencv2/core/cvstd.hpp:53,
from C:/opencv/sources/modules/core/include/opencv2/core/base.hpp:58,
from C:/opencv/sources/modules/core/include/opencv2/core.hpp:54,
from C:/opencv/sources/modules/highgui/include/opencv2/highgui.hpp:46,
from C:\opencv\sources\modules\highgui\src\precomp.hpp:45,
from C:\opencv\sources\modules\highgui\src\window_w32.cpp:42:
C:/mingw/mingw64/x86_64-w64-mingw32/include/string.h:62:18: note: declared here
char * __cdecl strcat(char * __restrict__ _Dest,const char * __restrict__ _Source);
^~~~~~
C:\opencv\sources\modules\highgui\src\window_w32.cpp:383:52: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
strcpy( rootKey, 1024, icvWindowPosRootKey );
^
C:\opencv\sources\modules\highgui\src\window_w32.cpp:383:52: error: too many arguments to function 'char* strcpy(char*, const char*)'
In file included from C:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/cstring:42,
from C:/opencv/sources/modules/core/include/opencv2/core/cvstd.hpp:53,
from C:/opencv/sources/modules/core/include/opencv2/core/base.hpp:58,
from C:/opencv/sources/modules/core/include/opencv2/core.hpp:54,
from C:/opencv/sources/modules/highgui/include/opencv2/highgui.hpp:46,
from C:\opencv\sources\modules\highgui\src\precomp.hpp:45,
from C:\opencv\sources\modules\highgui\src\window_w32.cpp:42:
C:/mingw/mingw64/x86_64-w64-mingw32/include/string.h:61:18: note: declared here
char * __cdecl strcpy(char * __restrict__ _Dest,const char * __restrict__ _Source);
^~~~~~
C:\opencv\sources\modules\highgui\src\window_w32.cpp:402:53: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
strcpy( oldestKey, 1024, currentKey );
^
C:\opencv\sources\modules\highgui\src\window_w32.cpp:402:53: error: too many arguments to function 'char* strcpy(char*, const char*)'
In file included from C:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/cstring:42,
from C:/opencv/sources/modules/core/include/opencv2/core/cvstd.hpp:53,
from C:/opencv/sources/modules/core/include/opencv2/core/base.hpp:58,
from C:/opencv/sources/modules/core/include/opencv2/core.hpp:54,
from C:/opencv/sources/modules/highgui/include/opencv2/highgui.hpp:46,
from C:\opencv\sources\modules\highgui\src\precomp.hpp:45,
from C:\opencv\sources\modules\highgui\src\window_w32.cpp:42:
C:/mingw/mingw64/x86_64-w64-mingw32/include/string.h:61:18: note: declared here
char * __cdecl strcpy(char * __restrict__ _Dest,const char * __restrict__ _Source);
^~~~~~
C:\opencv\sources\modules\highgui\src\window_w32.cpp: In function 'LRESULT HighGUIProc(HWND, UINT, WPARAM, LPARAM)':
C:\opencv\sources\modules\highgui\src\window_w32.cpp:1629:24: warning: left operand of comma operator has no effect [-Wunused-value]
} while (0,0); // (0,0) instead of (0) to avoid MSVC compiler warning C4127: "conditional expression is constant"
^
C:\opencv\sources\modules\highgui\src\window_w32.cpp: In function 'LRESULT MainWindowProc(HWND, UINT, WPARAM, LPARAM)':
C:\opencv\sources\modules\highgui\src\window_w32.cpp:1460:55: warning: this statement may fall through [-Wimplicit-fallthrough=]
pos->y = mi.rcMonitor.bottom - pos->cy; // snap to bottom edge
^
C:\opencv\sources\modules\highgui\src\window_w32.cpp:1463:5: note: here
case WM_ACTIVATE:
^~~~
C:\opencv\sources\modules\highgui\src\window_w32.cpp: In function 'int cvWaitKey(int)':
C:\opencv\sources\modules\highgui\src\window_w32.cpp:2075:21: warning: this statement may fall through [-Wimplicit-fallthrough=]
if ('S' == message.wParam && (::GetKeyState(VK_CONTROL)>>15))
^~
C:\opencv\sources\modules\highgui\src\window_w32.cpp:2078:17: note: here
default:
^~~~~~~
mingw32-make[2]: *** [modules\highgui\CMakeFiles\opencv_highgui.dir\build.make:91: modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_w32.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:1832: modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
mingw32-make: *** [Makefile:162: all] Error 2
在此先感谢您的帮助!
编辑:
由于参数问题导致错误,我将strcpy和strcat还原为strcpy_s和strcat_s,然后返回到此:
Scanning dependencies of target opencv_highgui
[ 81%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window.cpp.obj
[ 82%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/roiSelector.cpp.obj
[ 82%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_w32.cpp.obj
In file included from C:\opencv\sources\modules\highgui\src\window_w32.cpp:56:
C:/mingw/mingw64/x86_64-w64-mingw32/include/commctrl.h:8: error: unterminated #ifndef
#ifndef _INC_COMMCTRL
C:\opencv\sources\modules\highgui\src\window_w32.cpp: In function 'LRESULT HighGUIProc(HWND, UINT, WPARAM, LPARAM)':
C:\opencv\sources\modules\highgui\src\window_w32.cpp:1629:24: warning: left operand of comma operator has no effect [-Wunused-value]
} while (0,0); // (0,0) instead of (0) to avoid MSVC compiler warning C4127: "conditional expression is constant"
^
C:\opencv\sources\modules\highgui\src\window_w32.cpp: In function 'LRESULT MainWindowProc(HWND, UINT, WPARAM, LPARAM)':
C:\opencv\sources\modules\highgui\src\window_w32.cpp:1460:55: warning: this statement may fall through [-Wimplicit-fallthrough=]
pos->y = mi.rcMonitor.bottom - pos->cy; // snap to bottom edge
^
C:\opencv\sources\modules\highgui\src\window_w32.cpp:1463:5: note: here
case WM_ACTIVATE:
^~~~
C:\opencv\sources\modules\highgui\src\window_w32.cpp: In function 'int cvWaitKey(int)':
C:\opencv\sources\modules\highgui\src\window_w32.cpp:2075:21: warning: this statement may fall through [-Wimplicit-fallthrough=]
if ('S' == message.wParam && (::GetKeyState(VK_CONTROL)>>15))
^~
C:\opencv\sources\modules\highgui\src\window_w32.cpp:2078:17: note: here
default:
^~~~~~~
mingw32-make[2]: *** [modules\highgui\CMakeFiles\opencv_highgui.dir\build.make:91: modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_w32.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:1880: modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
mingw32-make: *** [Makefile:162: all] Error 2
编辑2:最终解决了该问题,感谢您的帮助。 commctrl.h文件最后需要一个额外的结尾。