Ask Your Question
0

Problem compiling OpenCV 2.4.13 with Cmake and MinGW

asked 2016-09-12 21:22:50 -0600

Juan Otoya gravatar image

I got this problem when trying to compile opencv using Cmake and mingw.

for Cmake: sourcecode is located in "C:\CPP Libraries\OpenCV-2.4.13\opencv\sources" where the binaries are goint to be build is in: "C:/CPP Libraries/OpenCV-2.4.13/opencv/build/x64/mingw"

I've already used Cmake to generate the makefile.

when i run the makefile:

C:\CPP Libraries\OpenCV-2.4.13\opencv\build\x64\mingw>mingw32-make

this is the output that I get after 31%

[ 31%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_w32.cpp.obj
C:\CPP Libraries\OpenCV-2.4.13\opencv\sources\modules\highgui\src\window_w32.cpp: In function 'int icvCreateTrackbar(const char*, const char*, int*, int, CvTrackbarCallback, CvTrackbarCallback2, void*)':
C:\CPP Libraries\OpenCV-2.4.13\opencv\sources\modules\highgui\src\window_w32.cpp:1853:81: error: 'BTNS_AUTOSIZE' was not declared in this scope
                                         WS_CHILD | CCS_TOP | TBSTYLE_WRAPABLE | BTNS_AUTOSIZE | BTNS_BUTTON,
                                                                                 ^
C:\CPP Libraries\OpenCV-2.4.13\opencv\sources\modules\highgui\src\window_w32.cpp:1853:97: error: 'BTNS_BUTTON' was not declared in this scope
                                         WS_CHILD | CCS_TOP | TBSTYLE_WRAPABLE | BTNS_AUTOSIZE | BTNS_BUTTON,
                                                                                                 ^
modules\highgui\CMakeFiles\opencv_highgui.dir\build.make:187: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_w32.cpp.obj' failed
mingw32-make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_w32.cpp.obj] Error 1
CMakeFiles\Makefile2:2203: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/all' failed
mingw32-make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

Does anyone knows a solution, because i have no clue about this one.

edit retag flag offensive close merge delete

Comments

it looks, like you're trying with an outdated mingw32 version.

rather get mingw64, and try again.

berak gravatar imageberak ( 2016-09-13 00:35:03 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2016-09-13 04:29:02 -0600

pklab gravatar image

At 31% the build process is building the core module... the highgui module comes around 40%. Is this a successive build or did you remove some (relevant) modules ? Did you have any warning while configure/generate ?

Sincerely mingw32-make.exe is the make of mingw64. I can build OCV 2.4.13 with TDM-GCC-64 like a charm.

BTW, the BTNS_AUTOSIZE symbol is defined in <MINGW_ROOT>/x86_64-w64-mingw32/include/commctrl.h which is common include file for TDM-GCC-64.

window_w32.cpp:50 includes commctrl.h which is supposed to exist because your error is later. (or your builds doesn't have defined WIN32 || _WIN32)

Maybe your issue is from mingw / windows_32 libs... check if the file commctrl.h exists in your mingw installation and if it contains the symbols BTNS_AUTOSIZE.

You can also test it with a simple program like this:

#include <iostream>
#include <windows.h>
#include <commctrl.h>
using namespace std;

int main()
{
    int test = BTNS_AUTOSIZE;
    cout << "Test should be 16: " << test << endl;
    return 0;
}

at the end... check/update your mingw end ensure you have the windows_32 lib.

edit flag offensive delete link more
0

answered 2017-05-18 12:32:09 -0600

I also faced the same problem. I found the solution.

in the modules/highgui/src/window_w32.cpp

please add this lines between the #endif and the #include <commctrl.h> lines like this

#  pragma GCC diagnostic ignored "-Wmissing-declarations"
#endif

/*start new code lines*/
#if (_WIN32_IE < 0x0500)
#pragma message("WARNING: Win32 UI needs to be compiled with _WIN32_IE >= 0x0500 (_WIN32_IE_IE50)")
#define _WIN32_IE 0x0500
#endif
/*end new code lines*/   

#include <commctrl.h>
#include <stdlib.h>
#include <string.h>

Here is the original link I found here

edit flag offensive delete link more

Comments

I literally made an account to upvote this, only to find out new accounts can't upvote.
Take this thank you message at least.
No idea why they haven't fixed it if it's already an issue on git.

IO gravatar imageIO ( 2018-05-18 18:29:38 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-09-12 21:22:50 -0600

Seen: 2,466 times

Last updated: May 18 '17