Как я могу исправить эту ошибку при компиляции OpenCV через mingw32-make? - PullRequest
0 голосов
/ 14 июня 2019

Я пытаюсь скомпилировать последнюю версию opencv 3 в windows для Mingw64, используя cmake-gui, и я столкнулся с некоторыми ошибками при компиляции исходных файлов.

У меня был целый ряд проблем, которые я решал, читая решения для других людей, но я столкнулся с проблемой, которую не могу исправить. Мне не удалось скомпилировать библиотеку highgui, и если я ее опущу, то компиляция пройдет хорошо.

Я использовал обычный mingw32-make, от Mingw 64.

Вот журнал ошибок, он довольно длинный и громоздкий, но я надеюсь, что он может дать некоторое представление:

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

Заранее спасибо за помощь!

EDIT:

Я вернул 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 понадобился дополнительный endif.

...